router.Run() can be called without parameters. #405

This commit is contained in:
Manu Mtz-Almeida
2015-08-16 16:19:51 +02:00
parent 2b3aa51738
commit ce2201c392
3 changed files with 76 additions and 20 deletions

7
gin.go
View File

@ -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
}