From 226d6ad22b6eecadf0b4344a5964cd7fd499bc90 Mon Sep 17 00:00:00 2001 From: Asim Aslam Date: Sun, 19 Apr 2020 00:41:03 +0100 Subject: [PATCH] log whats happening in http handler --- api/server/http/http.go | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/api/server/http/http.go b/api/server/http/http.go index 6615232d..518977e6 100644 --- a/api/server/http/http.go +++ b/api/server/http/http.go @@ -51,18 +51,22 @@ func (s *httpServer) Init(opts ...server.Option) error { } func (s *httpServer) Handle(path string, handler http.Handler) { - h := handlers.CombinedLoggingHandler(os.Stdout, handler) + // TODO: move this stuff out to one place with ServeHTTP // apply the wrappers, e.g. auth for _, wrapper := range s.opts.Wrappers { - h = wrapper(h) + handler = wrapper(handler) } + // wrap with cors if s.opts.EnableCORS { - h = cors.CombinedCORSHandler(h) + handler = cors.CombinedCORSHandler(handler) } - s.mux.Handle(path, h) + // wrap with logger + handler = handlers.CombinedLoggingHandler(os.Stdout, handler) + + s.mux.Handle(path, handler) } func (s *httpServer) Start() error {