1
0
mirror of https://github.com/labstack/echo.git synced 2024-12-24 20:14:31 +02:00

Putting Echo#Server back

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2015-11-15 13:32:21 -08:00
parent cba2724de3
commit 0163cddab5
3 changed files with 17 additions and 15 deletions

20
echo.go
View File

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

View File

@ -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()

View File

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