mirror of
https://github.com/labstack/echo.git
synced 2025-01-12 01:22:21 +02:00
Using same Server instance for http and tls
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
fe459537b7
commit
ed3c611321
11
echo.go
11
echo.go
@ -63,7 +63,6 @@ type (
|
|||||||
Echo struct {
|
Echo struct {
|
||||||
Server *http.Server
|
Server *http.Server
|
||||||
Listener net.Listener
|
Listener net.Listener
|
||||||
TLSServer *http.Server
|
|
||||||
TLSListener net.Listener
|
TLSListener net.Listener
|
||||||
tlsConfig *tls.Config
|
tlsConfig *tls.Config
|
||||||
DisableHTTP2 bool
|
DisableHTTP2 bool
|
||||||
@ -528,12 +527,8 @@ func (e *Echo) Start(address string) (err error) {
|
|||||||
|
|
||||||
// StartTLS starts the TLS server.
|
// StartTLS starts the TLS server.
|
||||||
func (e *Echo) StartTLS(address string, certFile, keyFile string) (err error) {
|
func (e *Echo) StartTLS(address string, certFile, keyFile string) (err error) {
|
||||||
if e.TLSServer == nil {
|
if e.Server == nil {
|
||||||
if e.Server == nil {
|
e.Server = &http.Server{Handler: e}
|
||||||
e.TLSServer = &http.Server{Handler: e}
|
|
||||||
} else {
|
|
||||||
e.TLSServer = e.Server
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
if e.TLSListener == nil {
|
if e.TLSListener == nil {
|
||||||
e.TLSListener, err = net.Listen("tcp", address)
|
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()))
|
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
|
// Stop stops the HTTP server
|
||||||
|
Loading…
Reference in New Issue
Block a user