fix http server handler (#1456)

pull/1461/head
Tony Chen 3 years ago committed by GitHub
parent 736fb38e79
commit aed6af7acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 8
      transport/http/server.go

@ -139,12 +139,12 @@ func NewServer(opts ...ServerOption) *Server {
for _, o := range opts {
o(srv)
}
srv.router = mux.NewRouter()
srv.router.Use(srv.filter())
srv.Server = &http.Server{
Handler: FilterChain(srv.filters...)(srv),
Handler: FilterChain(srv.filters...)(srv.router),
TLSConfig: srv.tlsConf,
}
srv.router = mux.NewRouter()
srv.router.Use(srv.filter())
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 {

Loading…
Cancel
Save