1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-01-14 02:33:03 +02:00

fix http server handler (#1456)

This commit is contained in:
Tony Chen 2021-09-09 23:12:48 +08:00 committed by GitHub
parent 736fb38e79
commit aed6af7acc
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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 {