HandlePath allows users to configure custom path handlers. refer: https://grpc-ecosystem.github.io/grpc-gateway/docs/operations/inject_router/
(meth string, pathPattern string, h HandlerFunc)
| 390 | // HandlePath allows users to configure custom path handlers. |
| 391 | // refer: https://grpc-ecosystem.github.io/grpc-gateway/docs/operations/inject_router/ |
| 392 | func (s *ServeMux) HandlePath(meth string, pathPattern string, h HandlerFunc) error { |
| 393 | compiler, err := httprule.Parse(pathPattern) |
| 394 | if err != nil { |
| 395 | return fmt.Errorf("parsing path pattern: %w", err) |
| 396 | } |
| 397 | tp := compiler.Compile() |
| 398 | pattern, err := NewPattern(tp.Version, tp.OpCodes, tp.Pool, tp.Verb) |
| 399 | if err != nil { |
| 400 | return fmt.Errorf("creating new pattern: %w", err) |
| 401 | } |
| 402 | s.Handle(meth, pattern, h) |
| 403 | return nil |
| 404 | } |
| 405 | |
| 406 | // ServeHTTP dispatches the request to the first handler whose pattern matches to r.Method and r.URL.Path. |
| 407 | func (s *ServeMux) ServeHTTP(w http.ResponseWriter, r *http.Request) { |