diff --git a/gin.go b/gin.go index ea9345aa..37e6e4dd 100644 --- a/gin.go +++ b/gin.go @@ -126,16 +126,18 @@ func (engine *Engine) ServeHTTP(writer http.ResponseWriter, request *http.Reques engine.router.ServeHTTP(writer, request) } -func (engine *Engine) Run(addr string) { +func (engine *Engine) Run(addr string) error { debugPrint("Listening and serving HTTP on %s", addr) if err := http.ListenAndServe(addr, engine); err != nil { - panic(err) + return err } + return nil } -func (engine *Engine) RunTLS(addr string, cert string, key string) { +func (engine *Engine) RunTLS(addr string, cert string, key string) error { debugPrint("Listening and serving HTTPS on %s", addr) if err := http.ListenAndServeTLS(addr, cert, key, engine); err != nil { - panic(err) + return err } + return nil }