2021-11-03 14:14:46 +00:00
|
|
|
//go:build lambda
|
2021-07-13 18:16:09 +00:00
|
|
|
// +build lambda
|
|
|
|
|
|
|
|
package router
|
|
|
|
|
|
|
|
import (
|
|
|
|
"context"
|
2021-07-13 19:01:50 +00:00
|
|
|
"net/http"
|
|
|
|
|
|
|
|
"github.com/appleboy/gorush/config"
|
|
|
|
"github.com/appleboy/gorush/logx"
|
2021-07-13 18:16:09 +00:00
|
|
|
|
|
|
|
"github.com/apex/gateway"
|
2021-08-15 08:12:08 +00:00
|
|
|
"github.com/golang-queue/queue"
|
2021-07-13 18:16:09 +00:00
|
|
|
)
|
|
|
|
|
|
|
|
// RunHTTPServer provide run http or https protocol.
|
2021-08-02 06:07:30 +00:00
|
|
|
func RunHTTPServer(ctx context.Context, cfg *config.ConfYaml, q *queue.Queue, s ...*http.Server) (err error) {
|
2021-07-13 18:16:09 +00:00
|
|
|
if !cfg.Core.Enabled {
|
2021-07-13 19:01:50 +00:00
|
|
|
logx.LogAccess.Debug("httpd server is disabled.")
|
2021-07-13 18:16:09 +00:00
|
|
|
return nil
|
|
|
|
}
|
|
|
|
|
2021-07-13 19:01:50 +00:00
|
|
|
logx.LogAccess.Info("HTTPD server is running on " + cfg.Core.Port + " port.")
|
2021-07-13 18:16:09 +00:00
|
|
|
|
2021-07-16 04:10:34 +00:00
|
|
|
return gateway.ListenAndServe(cfg.Core.Address+":"+cfg.Core.Port, routerEngine(cfg, q))
|
2021-07-13 18:16:09 +00:00
|
|
|
}
|