diff --git a/echo.go b/echo.go index 2359e15d..d226e62f 100644 --- a/echo.go +++ b/echo.go @@ -153,7 +153,7 @@ func New() (e *Echo) { // Defaults //---------- - e.HTTP2(true) + e.HTTP2(false) e.notFoundHandler = func(c *Context) error { return NewHTTPError(http.StatusNotFound) } @@ -423,15 +423,25 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) { e.pool.Put(c) } +// Server returns the internal *http.Server +func (e *Echo) Server(addr string) *http.Server { + s := &http.Server{Addr: addr} + s.Handler = e + if e.http2 { + http2.ConfigureServer(s, nil) + } + return s +} + // Run runs a server. func (e *Echo) Run(addr string) { - s := &http.Server{Addr: addr} + s := e.Server(addr) e.run(s) } // RunTLS runs a server with TLS configuration. func (e *Echo) RunTLS(addr, certFile, keyFile string) { - s := &http.Server{Addr: addr} + s := e.Server(addr) e.run(s, certFile, keyFile) } @@ -446,10 +456,6 @@ func (e *Echo) RunTLSServer(srv *http.Server, certFile, keyFile string) { } func (e *Echo) run(s *http.Server, files ...string) { - s.Handler = e - if e.http2 { - http2.ConfigureServer(s, nil) - } if len(files) == 0 { log.Fatal(s.ListenAndServe()) } else if len(files) == 2 { diff --git a/echo_test.go b/echo_test.go index 8e5b3d9e..1b4279c1 100644 --- a/echo_test.go +++ b/echo_test.go @@ -375,6 +375,12 @@ 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 testMethod(t *testing.T, method, path string, e *Echo) { m := fmt.Sprintf("%c%s", method[0], strings.ToLower(method[1:])) p := reflect.ValueOf(path) diff --git a/website/docs/index.md b/website/docs/index.md index 24a8e978..1f2f633a 100644 --- a/website/docs/index.md +++ b/website/docs/index.md @@ -38,7 +38,7 @@ Echo is a fast HTTP router (zero dynamic memory allocation) and micro web framew ## Performance -![Performance](http://i.imgur.com/dTBFmte.png) + ## Getting Started