all repos — homestead @ 5f2f546708cbe89a75131797b9f6d7f274656c43

Code for my website

ensure http always has a logger

Alan Pearce
commit

5f2f546708cbe89a75131797b9f6d7f274656c43

parent

52c7a311770809e20c790078ddf27ea4fa10c77e

1 file changed, 2 insertions(+), 8 deletions(-)

changed files
M shared/http/mux.goshared/http/mux.go
@@ -27,20 +27,14 @@ *http.ServeMux
} // NewServeMux creates a new ServeMux with a default error handler. -func NewServeMux() *ServeMux { +func NewServeMux(logger *log.Logger) *ServeMux { return &ServeMux{ ServeMux: http.NewServeMux(), + log: logger, errorHandler: func(err Error, w http.ResponseWriter, _ *http.Request) { http.Error(w, err.Error(), err.StatusCode()) }, } -} - -// WithLogger sets the logger for this ServeMux and returns the ServeMux. -func (sm *ServeMux) WithLogger(logger *log.Logger) *ServeMux { - sm.log = logger - - return sm } // Handle registers the handler for the given pattern.