diff --git a/echo.go b/echo.go index efe2e3e7..1a400e73 100644 --- a/echo.go +++ b/echo.go @@ -467,22 +467,23 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) { } // Server returns the internal *http.Server. -// func (e *Echo) Server(addr string) *http.Server { -// s := &http.Server{Addr: addr, Handler: e} -// if e.http2 { -// http2.ConfigureServer(s, nil) -// } -// return s -// } +func (e *Echo) Server(addr string) *http.Server { + s := &http.Server{Addr: addr, Handler: e} + // TODO: Remove in Go 1.6+ + if e.http2 { + http2.ConfigureServer(s, nil) + } + return s +} // Run runs a server. func (e *Echo) Run(addr string) { - e.run(&http.Server{Addr: addr}) + e.run(e.Server(addr)) } // RunTLS runs a server with TLS configuration. func (e *Echo) RunTLS(addr, crtFile, keyFile string) { - e.run(&http.Server{Addr: addr}, crtFile, keyFile) + e.run(e.Server(addr), crtFile, keyFile) } // RunServer runs a custom server. @@ -497,6 +498,7 @@ func (e *Echo) RunTLSServer(s *http.Server, crtFile, keyFile string) { func (e *Echo) run(s *http.Server, files ...string) { s.Handler = e + // TODO: Remove in Go 1.6+ if e.http2 { http2.ConfigureServer(s, nil) } diff --git a/echo_test.go b/echo_test.go index 4688d79e..9710dd24 100644 --- a/echo_test.go +++ b/echo_test.go @@ -400,11 +400,11 @@ func TestEchoHTTPError(t *testing.T) { assert.Equal(t, m, he.Error()) } -// func TestEchoServer(t *testing.T) { -// e := New() -// s := e.Server(":1323") -// assert.IsType(t, &http.Server{}, s) -// } +func TestEchoServer(t *testing.T) { + e := New() + s := e.Server(":1323") + assert.IsType(t, &http.Server{}, s) +} // func TestStripTrailingSlash(t *testing.T) { // e := New() diff --git a/recipes/graceful-shutdown/grace/server.go b/recipes/graceful-shutdown/grace/server.go index da3dc0b7..3a19c9b1 100644 --- a/recipes/graceful-shutdown/grace/server.go +++ b/recipes/graceful-shutdown/grace/server.go @@ -18,7 +18,7 @@ func main() { s := e.Server(":1323") // HTTP2 is currently enabled by default in echo.New(). To override TLS handshake errors - // you will need to override the TLSConfig for the server so it does not attempt to valudate + // you will need to override the TLSConfig for the server so it does not attempt to validate // the connection using TLS as required by HTTP2 s.TLSConfig = nil