mirror of
https://github.com/labstack/echo.git
synced 2024-12-24 20:14:31 +02:00
Refactor tls config
Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
parent
2eb5d97b19
commit
2fab27a378
@ -199,8 +199,8 @@ type (
|
||||
Config struct {
|
||||
Address string // TCP address to listen on.
|
||||
Listener net.Listener // Custom `net.Listener`. If set, server accepts connections on it.
|
||||
TLSCertfile string // TLS certificate file path.
|
||||
TLSKeyfile string // TLS key file path.
|
||||
TLSCertFile string // TLS certificate file path.
|
||||
TLSKeyFile string // TLS key file path.
|
||||
ReadTimeout time.Duration // Maximum duration before timing out read of the request.
|
||||
WriteTimeout time.Duration // Maximum duration before timing out write of the response.
|
||||
}
|
||||
|
@ -41,8 +41,8 @@ func New(addr string) *Server {
|
||||
func WithTLS(addr, certFile, keyFile string) *Server {
|
||||
c := engine.Config{
|
||||
Address: addr,
|
||||
TLSCertfile: certFile,
|
||||
TLSKeyfile: keyFile,
|
||||
TLSCertFile: certFile,
|
||||
TLSKeyFile: keyFile,
|
||||
}
|
||||
return WithConfig(c)
|
||||
}
|
||||
@ -111,16 +111,16 @@ func (s *Server) Start() error {
|
||||
|
||||
func (s *Server) startDefaultListener() error {
|
||||
c := s.config
|
||||
if c.TLSCertfile != "" && c.TLSKeyfile != "" {
|
||||
return s.ListenAndServeTLS(c.Address, c.TLSCertfile, c.TLSKeyfile)
|
||||
if c.TLSCertFile != "" && c.TLSKeyFile != "" {
|
||||
return s.ListenAndServeTLS(c.Address, c.TLSCertFile, c.TLSKeyFile)
|
||||
}
|
||||
return s.ListenAndServe(c.Address)
|
||||
}
|
||||
|
||||
func (s *Server) startCustomListener() error {
|
||||
c := s.config
|
||||
if c.TLSCertfile != "" && c.TLSKeyfile != "" {
|
||||
return s.ServeTLS(c.Listener, c.TLSCertfile, c.TLSKeyfile)
|
||||
if c.TLSCertFile != "" && c.TLSKeyFile != "" {
|
||||
return s.ServeTLS(c.Listener, c.TLSCertFile, c.TLSKeyFile)
|
||||
}
|
||||
return s.Serve(c.Listener)
|
||||
}
|
||||
|
@ -39,8 +39,8 @@ func New(addr string) *Server {
|
||||
func WithTLS(addr, certFile, keyFile string) *Server {
|
||||
c := engine.Config{
|
||||
Address: addr,
|
||||
TLSCertfile: certFile,
|
||||
TLSKeyfile: keyFile,
|
||||
TLSCertFile: certFile,
|
||||
TLSKeyFile: keyFile,
|
||||
}
|
||||
return WithConfig(c)
|
||||
}
|
||||
@ -109,8 +109,8 @@ func (s *Server) Start() error {
|
||||
|
||||
func (s *Server) startDefaultListener() error {
|
||||
c := s.config
|
||||
if c.TLSCertfile != "" && c.TLSKeyfile != "" {
|
||||
return s.ListenAndServeTLS(c.TLSCertfile, c.TLSKeyfile)
|
||||
if c.TLSCertFile != "" && c.TLSKeyFile != "" {
|
||||
return s.ListenAndServeTLS(c.TLSCertFile, c.TLSKeyFile)
|
||||
}
|
||||
return s.ListenAndServe()
|
||||
}
|
||||
|
@ -33,8 +33,8 @@ func New(addr string) *Server {
|
||||
func NewTLS(addr, certFile, keyFile string) *Server {
|
||||
c := &engine.Config{
|
||||
Address: addr,
|
||||
TLSCertfile: certFile,
|
||||
TLSKeyfile: keyFile,
|
||||
TLSCertFile: certFile,
|
||||
TLSKeyFile: keyFile,
|
||||
}
|
||||
return NewConfig(c)
|
||||
}
|
||||
@ -84,8 +84,8 @@ func (s *Server) SetLogger(l *log.Logger) {
|
||||
func (s *Server) Start() {
|
||||
s.Addr = s.config.Address
|
||||
s.Handler = s
|
||||
certFile := s.config.TLSCertfile
|
||||
keyFile := s.config.TLSKeyfile
|
||||
certFile := s.config.TLSCertFile
|
||||
keyFile := s.config.TLSKeyFile
|
||||
if certFile != "" && keyFile != "" {
|
||||
s.logger.Fatal(s.ListenAndServeTLS(certFile, keyFile))
|
||||
} else {
|
||||
|
Loading…
Reference in New Issue
Block a user