1
0
mirror of https://github.com/go-kratos/kratos.git synced 2025-03-17 21:07:54 +02:00

http: handle default mux (#2033)

This commit is contained in:
Tony Chen 2022-05-23 23:52:25 +08:00 committed by GitHub
parent 655fe37188
commit 6eae1745bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 8 additions and 0 deletions

View File

@ -12,6 +12,12 @@ import (
// SupportPackageIsVersion1 These constants should not be referenced from any other code.
const SupportPackageIsVersion1 = true
// Request type net/http.
type Request = http.Request
// ResponseWriter type net/http.
type ResponseWriter = http.ResponseWriter
// DecodeRequestFunc is decode request func.
type DecodeRequestFunc func(*http.Request, interface{}) error

View File

@ -149,6 +149,8 @@ func NewServer(opts ...ServerOption) *Server {
o(srv)
}
srv.router = mux.NewRouter().StrictSlash(srv.strictSlash)
srv.router.NotFoundHandler = http.DefaultServeMux
srv.router.MethodNotAllowedHandler = http.DefaultServeMux
srv.router.Use(srv.filter())
srv.Server = &http.Server{
Handler: FilterChain(srv.filters...)(srv.router),