support run HTTP server with specific net.Listener (#2023)

This commit is contained in:
Manjusaka
2019-09-30 09:12:22 +08:00
committed by thinkerou
parent 9b9f4fab34
commit 79840bc1c6
2 changed files with 45 additions and 0 deletions
+9
View File
@@ -338,6 +338,15 @@ func (engine *Engine) RunFd(fd int) (err error) {
return
}
defer listener.Close()
err = engine.RunListener(listener)
return
}
// RunListener attaches the router to a http.Server and starts listening and serving HTTP requests
// through the specified net.Listener
func (engine *Engine) RunListener(listener net.Listener) (err error) {
debugPrint("Listening and serving HTTP on listener what's bind with address@%s", listener.Addr())
defer func() { debugPrintError(err) }()
err = http.Serve(listener, engine)
return
}