1
0
mirror of https://github.com/labstack/echo.git synced 2025-07-03 00:56:59 +02:00

Dropping mutex from ServeHTTP

Signed-off-by: Vishal Rana <vr@labstack.com>
This commit is contained in:
Vishal Rana
2017-05-13 14:12:35 -07:00
parent 0e134ee37c
commit 8f5fb6395a

13
echo.go
View File

@ -80,8 +80,8 @@ type (
Validator Validator Validator Validator
Renderer Renderer Renderer Renderer
AutoTLSManager autocert.Manager AutoTLSManager autocert.Manager
Mutex sync.RWMutex // Mutex sync.RWMutex
Logger Logger Logger Logger
} }
// Route contains a handler and information for matching against requests. // Route contains a handler and information for matching against requests.
@ -525,8 +525,8 @@ func (e *Echo) ReleaseContext(c Context) {
// ServeHTTP implements `http.Handler` interface, which serves HTTP requests. // ServeHTTP implements `http.Handler` interface, which serves HTTP requests.
func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) { func (e *Echo) ServeHTTP(w http.ResponseWriter, r *http.Request) {
// Acquire lock // Acquire lock
e.Mutex.RLock() // e.Mutex.RLock()
defer e.Mutex.RUnlock() // defer e.Mutex.RUnlock()
// Acquire context // Acquire context
c := e.pool.Get().(*context) c := e.pool.Get().(*context)
@ -598,7 +598,6 @@ func (e *Echo) startTLS(address string) error {
} }
// StartServer starts a custom http server. // StartServer starts a custom http server.
func (e *Echo) StartServer(s *http.Server) (err error) { func (e *Echo) StartServer(s *http.Server) (err error) {
// Setup // Setup
e.colorer.SetOutput(e.Logger.Output()) e.colorer.SetOutput(e.Logger.Output())
@ -620,7 +619,7 @@ func (e *Echo) StartServer(s *http.Server) (err error) {
} }
} }
if !e.HideBanner { if !e.HideBanner {
e.colorer.Printf("🚀 http server started on %s\n", e.colorer.Green(e.Listener.Addr())) e.colorer.Printf(" http server started on %s\n", e.colorer.Green(e.Listener.Addr()))
} }
return s.Serve(e.Listener) return s.Serve(e.Listener)
} }
@ -632,7 +631,7 @@ func (e *Echo) StartServer(s *http.Server) (err error) {
e.TLSListener = tls.NewListener(l, s.TLSConfig) e.TLSListener = tls.NewListener(l, s.TLSConfig)
} }
if !e.HideBanner { if !e.HideBanner {
e.colorer.Printf("🚀 https server started on %s\n", e.colorer.Green(e.TLSListener.Addr())) e.colorer.Printf(" https server started on %s\n", e.colorer.Green(e.TLSListener.Addr()))
} }
return s.Serve(e.TLSListener) return s.Serve(e.TLSListener)
} }