2021-04-16 15:10:07 +08:00
|
|
|
package starter
|
|
|
|
|
|
|
|
|
|
import (
|
2021-07-28 18:03:19 +08:00
|
|
|
"mayfly-go/base/config"
|
2021-04-16 15:10:07 +08:00
|
|
|
"mayfly-go/base/global"
|
2021-04-21 10:22:09 +08:00
|
|
|
|
|
|
|
|
"github.com/gin-gonic/gin"
|
2021-04-16 15:10:07 +08:00
|
|
|
)
|
|
|
|
|
|
2021-04-21 10:22:09 +08:00
|
|
|
func RunWebServer(web *gin.Engine) {
|
2021-07-28 18:03:19 +08:00
|
|
|
server := config.Conf.Server
|
|
|
|
|
port := server.GetPort()
|
|
|
|
|
if app := config.Conf.App; app != nil {
|
2021-04-16 15:10:07 +08:00
|
|
|
global.Log.Infof("%s- Listening and serving HTTP on %s", app.GetAppInfo(), port)
|
|
|
|
|
} else {
|
|
|
|
|
global.Log.Infof("Listening and serving HTTP on %s", port)
|
|
|
|
|
}
|
2021-07-28 18:03:19 +08:00
|
|
|
|
|
|
|
|
if server.Tls != nil && server.Tls.Enable {
|
|
|
|
|
web.RunTLS(port, server.Tls.CertFile, server.Tls.KeyFile)
|
|
|
|
|
} else {
|
|
|
|
|
web.Run(port)
|
|
|
|
|
}
|
2021-04-16 15:10:07 +08:00
|
|
|
}
|