From bc25b3d81bf10b799c782598cc367a4ebce5e137 Mon Sep 17 00:00:00 2001 From: Tony Chen Date: Mon, 23 May 2022 23:52:25 +0800 Subject: [PATCH] http: handle default mux (#2033) --- transport/http/codec.go | 6 ++++++ transport/http/server.go | 2 ++ 2 files changed, 8 insertions(+) diff --git a/transport/http/codec.go b/transport/http/codec.go index 1df09e303..948b1cd19 100644 --- a/transport/http/codec.go +++ b/transport/http/codec.go @@ -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 diff --git a/transport/http/server.go b/transport/http/server.go index b6e7534be..c9a0597f2 100644 --- a/transport/http/server.go +++ b/transport/http/server.go @@ -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),