http: handle default mux (#2033)

pull/2035/head
Tony Chen 3 years ago committed by GitHub
parent 655fe37188
commit 6eae1745bd
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
  1. 6
      transport/http/codec.go
  2. 2
      transport/http/server.go

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

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

Loading…
Cancel
Save