From 63560e058b32fca38583bb81f524009f0bb02065 Mon Sep 17 00:00:00 2001 From: Janos Guljas Date: Thu, 26 Sep 2019 01:07:24 +0200 Subject: [PATCH] server: remove nilRecoveryHandler --- server/handlers.go | 12 ------------ server/server.go | 10 ++++------ 2 files changed, 4 insertions(+), 18 deletions(-) diff --git a/server/handlers.go b/server/handlers.go index 3f1b709..8125238 100644 --- a/server/handlers.go +++ b/server/handlers.go @@ -17,18 +17,6 @@ import ( "resenje.org/web/recovery" ) -// Recovery handler that does not write anything to response. -// It is useful as the firs handler in chain if a handler that -// transforms response needs to be before other recovery handler, -// like compress handler. -func (s *Server) nilRecoveryHandler(h http.Handler) http.Handler { - return recovery.New(h, - recovery.WithLabel(s.Version()), - recovery.WithLogFunc(s.logger.Errorf), - recovery.WithNotifier(s.emailService), - ) -} - func newRedirectDomainHandler(domain, httpsPort string) http.Handler { return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { _, port, _ := net.SplitHostPort(r.Host) diff --git a/server/server.go b/server/server.go index 1620c47..56863a6 100644 --- a/server/server.go +++ b/server/server.go @@ -106,12 +106,12 @@ func New(o Options) (s *Server, err error) { internalRouter := newInternalRouter(s) if o.ListenInternal != "" { s.servers.Add("internal HTTP", o.ListenInternal, httpServer.New( - s.nilRecoveryHandler(internalRouter), + internalRouter, )) } if o.ListenInternalTLS != "" { s.servers.Add("internal TLS HTTP", o.ListenInternalTLS, httpServer.New( - s.nilRecoveryHandler(internalRouter), + internalRouter, httpServer.WithTLSConfig(tlsConfig), )) } @@ -291,9 +291,7 @@ func (s *Server) WithHTTP(o HTTPOptions) (err error) { if httpsPort != "" { h = redirectHTTPSHandler(h, httpsPort) } - server := httpServer.New( - s.nilRecoveryHandler(h), - ) + server := httpServer.New(h) server.IdleTimeout = idleTimeout server.ReadTimeout = readTimeout server.WriteTimeout = writeTimeout @@ -306,7 +304,7 @@ func (s *Server) WithHTTP(o HTTPOptions) (err error) { if o.ListenTLS != "" { server := httpServer.New( - s.nilRecoveryHandler(router), + router, httpServer.WithTLSConfig(tlsConfig), ) server.IdleTimeout = idleTimeout