router.Run() can be called without parameters. #405
This commit is contained in:
7
gin.go
7
gin.go
@ -228,11 +228,12 @@ func iterate(path, method string, routes RoutesInfo, root *node) RoutesInfo {
|
||||
// Run attaches the router to a http.Server and starts listening and serving HTTP requests.
|
||||
// It is a shortcut for http.ListenAndServe(addr, router)
|
||||
// Note: this method will block the calling goroutine undefinitelly unless an error happens.
|
||||
func (engine *Engine) Run(addr string) (err error) {
|
||||
debugPrint("Listening and serving HTTP on %s\n", addr)
|
||||
func (engine *Engine) Run(addr ...string) (err error) {
|
||||
defer func() { debugPrintError(err) }()
|
||||
|
||||
err = http.ListenAndServe(addr, engine)
|
||||
address := resolveAddress(addr)
|
||||
debugPrint("Listening and serving HTTP on %s\n", address)
|
||||
err = http.ListenAndServe(address, engine)
|
||||
return
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user