gorush/router/server_lambda.go

28 lines
649 B
Go
Raw Normal View History

//go:build lambda
2021-07-13 18:16:09 +00:00
// +build lambda
package router
import (
"context"
"net/http"
"github.com/appleboy/gorush/config"
"github.com/appleboy/gorush/logx"
2021-07-13 18:16:09 +00:00
"github.com/apex/gateway"
"github.com/golang-queue/queue"
2021-07-13 18:16:09 +00:00
)
// RunHTTPServer provide run http or https protocol.
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 {
logx.LogAccess.Debug("httpd server is disabled.")
2021-07-13 18:16:09 +00:00
return nil
}
logx.LogAccess.Info("HTTPD server is running on " + cfg.Core.Port + " port.")
2021-07-13 18:16:09 +00:00
return gateway.ListenAndServe(cfg.Core.Address+":"+cfg.Core.Port, routerEngine(cfg, q))
2021-07-13 18:16:09 +00:00
}