Created
September 10, 2022 19:44
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// Listen serves HTTP requests from the given addr. | |
// | |
// app.Listen(":8080") | |
// app.Listen("127.0.0.1:8080") | |
func (app *App) Listen(addr string) error { | |
// Start prefork | |
if app.config.Prefork { | |
return app.prefork(app.config.Network, addr, nil) | |
} | |
// Setup listener | |
ln, err := net.Listen(app.config.Network, addr) | |
if err != nil { | |
return err | |
} | |
// prepare the server for the start | |
app.startupProcess() | |
// Print startup message | |
if !app.config.DisableStartupMessage { | |
app.startupMessage(ln.Addr().String(), false, "") | |
} | |
// Print routes | |
if app.config.EnablePrintRoutes { | |
app.printRoutesMessage() | |
} | |
// Start listening | |
return app.server.Serve(ln) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment