From aed6af7acccf03d0da104c20fbdbe03274edf04c Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Thu, 9 Sep 2021 23:12:48 +0800 Subject: [PATCH] fix http server handler (#1456) --- transport/http/server.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/transport/http/server.go b/transport/http/server.go index fd78ab3b0..d5131de58 100644 --- a/transport/http/server.go +++ b/transport/http/server.go @@ -139,12 +139,12 @@ func NewServer(opts ...ServerOption) *Server { for _, o := range opts { o(srv) } - srv.Server = &http.Server{ - Handler: FilterChain(srv.filters...)(srv), - TLSConfig: srv.tlsConf, - } srv.router = mux.NewRouter() srv.router.Use(srv.filter()) + srv.Server = &http.Server{ + Handler: FilterChain(srv.filters...)(srv.router), + TLSConfig: srv.tlsConf, + } return srv } @@ -170,7 +170,7 @@ func (s *Server) HandleFunc(path string, h http.HandlerFunc) { // ServeHTTP should write reply headers and data to the ResponseWriter and then return. func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) { - s.router.ServeHTTP(res, req) + s.Handler.ServeHTTP(res, req) } func (s *Server) filter() mux.MiddlewareFunc {