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

Using same Server instance for http and tls

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana 2016-09-23 13:31:33 -07:00
parent fe459537b7
commit ed3c611321

View File

@ -63,7 +63,6 @@ type (
Echo struct {
Server *http.Server
Listener net.Listener
TLSServer *http.Server
TLSListener net.Listener
tlsConfig *tls.Config
DisableHTTP2 bool
@ -528,12 +527,8 @@ func (e *Echo) Start(address string) (err error) {
// StartTLS starts the TLS server.
func (e *Echo) StartTLS(address string, certFile, keyFile string) (err error) {
if e.TLSServer == nil {
if e.Server == nil {
e.TLSServer = &http.Server{Handler: e}
} else {
e.TLSServer = e.Server
}
e.Server = &http.Server{Handler: e}
}
if e.TLSListener == nil {
e.TLSListener, err = net.Listen("tcp", address)
@ -555,7 +550,7 @@ func (e *Echo) StartTLS(address string, certFile, keyFile string) (err error) {
}
}
e.Logger.Printf(" ⇛ https server started on %v", e.Logger.Color().Green(e.TLSListener.Addr()))
return e.TLSServer.Serve(e.TLSListener)
return e.Server.Serve(e.TLSListener)
}
// Stop stops the HTTP server