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:
parent
cba2724de3
commit
0163cddab5
20
echo.go
20
echo.go
@ -467,22 +467,23 @@ func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Server returns the internal *http.Server.
|
// Server returns the internal *http.Server.
|
||||||
// func (e *Echo) Server(addr string) *http.Server {
|
func (e *Echo) Server(addr string) *http.Server {
|
||||||
// s := &http.Server{Addr: addr, Handler: e}
|
s := &http.Server{Addr: addr, Handler: e}
|
||||||
// if e.http2 {
|
// TODO: Remove in Go 1.6+
|
||||||
// http2.ConfigureServer(s, nil)
|
if e.http2 {
|
||||||
// }
|
http2.ConfigureServer(s, nil)
|
||||||
// return s
|
}
|
||||||
// }
|
return s
|
||||||
|
}
|
||||||
|
|
||||||
// Run runs a server.
|
// Run runs a server.
|
||||||
func (e *Echo) Run(addr string) {
|
func (e *Echo) Run(addr string) {
|
||||||
e.run(&http.Server{Addr: addr})
|
e.run(e.Server(addr))
|
||||||
}
|
}
|
||||||
|
|
||||||
// RunTLS runs a server with TLS configuration.
|
// RunTLS runs a server with TLS configuration.
|
||||||
func (e *Echo) RunTLS(addr, crtFile, keyFile string) {
|
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.
|
// 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) {
|
func (e *Echo) run(s *http.Server, files ...string) {
|
||||||
s.Handler = e
|
s.Handler = e
|
||||||
|
// TODO: Remove in Go 1.6+
|
||||||
if e.http2 {
|
if e.http2 {
|
||||||
http2.ConfigureServer(s, nil)
|
http2.ConfigureServer(s, nil)
|
||||||
}
|
}
|
||||||
|
10
echo_test.go
10
echo_test.go
@ -400,11 +400,11 @@ func TestEchoHTTPError(t *testing.T) {
|
|||||||
assert.Equal(t, m, he.Error())
|
assert.Equal(t, m, he.Error())
|
||||||
}
|
}
|
||||||
|
|
||||||
// func TestEchoServer(t *testing.T) {
|
func TestEchoServer(t *testing.T) {
|
||||||
// e := New()
|
e := New()
|
||||||
// s := e.Server(":1323")
|
s := e.Server(":1323")
|
||||||
// assert.IsType(t, &http.Server{}, s)
|
assert.IsType(t, &http.Server{}, s)
|
||||||
// }
|
}
|
||||||
|
|
||||||
// func TestStripTrailingSlash(t *testing.T) {
|
// func TestStripTrailingSlash(t *testing.T) {
|
||||||
// e := New()
|
// e := New()
|
||||||
|
@ -18,7 +18,7 @@ func main() {
|
|||||||
s := e.Server(":1323")
|
s := e.Server(":1323")
|
||||||
|
|
||||||
// HTTP2 is currently enabled by default in echo.New(). To override TLS handshake errors
|
// 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
|
// the connection using TLS as required by HTTP2
|
||||||
s.TLSConfig = nil
|
s.TLSConfig = nil
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user