From 7aa51dc3938dc404e13f948a017bb9380ca1d10f Mon Sep 17 00:00:00 2001 From: Javier Provecho Fernandez Date: Sun, 4 Jan 2015 02:23:49 +0100 Subject: [PATCH] Solve #164 --- gin.go | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) 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 }