Skip to content

Commit

Permalink
Using same Server instance for http and tls
Browse files Browse the repository at this point in the history
Signed-off-by: Vishal Rana <[email protected]>
  • Loading branch information
vishr committed Sep 23, 2016
1 parent fe45953 commit ed3c611
Showing 1 changed file with 3 additions and 8 deletions.
11 changes: 3 additions & 8 deletions echo.go
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@ type (
Echo struct {
Server *http.Server
Listener net.Listener
TLSServer *http.Server
TLSListener net.Listener
tlsConfig *tls.Config
DisableHTTP2 bool
Expand Down Expand Up @@ -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
}
if e.Server == nil {
e.Server = &http.Server{Handler: e}
}
if e.TLSListener == nil {
e.TLSListener, err = net.Listen("tcp", address)
Expand All @@ -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
Expand Down

0 comments on commit ed3c611

Please sign in to comment.