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:
parent
736fb38e79
commit
aed6af7acc
@ -139,12 +139,12 @@ func NewServer(opts ...ServerOption) *Server {
|
|||||||
for _, o := range opts {
|
for _, o := range opts {
|
||||||
o(srv)
|
o(srv)
|
||||||
}
|
}
|
||||||
srv.Server = &http.Server{
|
|
||||||
Handler: FilterChain(srv.filters...)(srv),
|
|
||||||
TLSConfig: srv.tlsConf,
|
|
||||||
}
|
|
||||||
srv.router = mux.NewRouter()
|
srv.router = mux.NewRouter()
|
||||||
srv.router.Use(srv.filter())
|
srv.router.Use(srv.filter())
|
||||||
|
srv.Server = &http.Server{
|
||||||
|
Handler: FilterChain(srv.filters...)(srv.router),
|
||||||
|
TLSConfig: srv.tlsConf,
|
||||||
|
}
|
||||||
return srv
|
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.
|
// ServeHTTP should write reply headers and data to the ResponseWriter and then return.
|
||||||
func (s *Server) ServeHTTP(res http.ResponseWriter, req *http.Request) {
|
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 {
|
func (s *Server) filter() mux.MiddlewareFunc {
|
||||||
|
Loading…
Reference in New Issue
Block a user