1
0
mirror of https://github.com/astaxie/beego.git synced 2024-11-22 15:20:54 +00:00

Fixes #3995 Use handlers with middleware when starting Graceful server

This commit is contained in:
Bharat Patel 2020-05-18 10:00:14 -07:00
parent 8f3d1c5f42
commit 075db4773b

4
app.go
View File

@ -123,7 +123,7 @@ func (app *App) Run(mws ...MiddleWare) {
httpsAddr = fmt.Sprintf("%s:%d", BConfig.Listen.HTTPSAddr, BConfig.Listen.HTTPSPort) httpsAddr = fmt.Sprintf("%s:%d", BConfig.Listen.HTTPSAddr, BConfig.Listen.HTTPSPort)
app.Server.Addr = httpsAddr app.Server.Addr = httpsAddr
} }
server := grace.NewServer(httpsAddr, app.Handlers) server := grace.NewServer(httpsAddr, app.Server.Handler)
server.Server.ReadTimeout = app.Server.ReadTimeout server.Server.ReadTimeout = app.Server.ReadTimeout
server.Server.WriteTimeout = app.Server.WriteTimeout server.Server.WriteTimeout = app.Server.WriteTimeout
if BConfig.Listen.EnableMutualHTTPS { if BConfig.Listen.EnableMutualHTTPS {
@ -152,7 +152,7 @@ func (app *App) Run(mws ...MiddleWare) {
} }
if BConfig.Listen.EnableHTTP { if BConfig.Listen.EnableHTTP {
go func() { go func() {
server := grace.NewServer(addr, app.Handlers) server := grace.NewServer(addr, app.Server.Handler)
server.Server.ReadTimeout = app.Server.ReadTimeout server.Server.ReadTimeout = app.Server.ReadTimeout
server.Server.WriteTimeout = app.Server.WriteTimeout server.Server.WriteTimeout = app.Server.WriteTimeout
if BConfig.Listen.ListenTCP4 { if BConfig.Listen.ListenTCP4 {