Match registers a new route for multiple HTTP methods and path with matching handler in the router with optional route-level middleware. Panics on error.
(methods []string, path string, handler HandlerFunc, middleware ...MiddlewareFunc)
| 567 | // Match registers a new route for multiple HTTP methods and path with matching |
| 568 | // handler in the router with optional route-level middleware. Panics on error. |
| 569 | func (e *Echo) Match(methods []string, path string, handler HandlerFunc, middleware ...MiddlewareFunc) Routes { |
| 570 | errs := make([]error, 0) |
| 571 | ris := make(Routes, 0) |
| 572 | for _, m := range methods { |
| 573 | ri, err := e.AddRoute(Route{ |
| 574 | Method: m, |
| 575 | Path: path, |
| 576 | Handler: handler, |
| 577 | Middlewares: middleware, |
| 578 | }) |
| 579 | if err != nil { |
| 580 | errs = append(errs, err) |
| 581 | continue |
| 582 | } |
| 583 | ris = append(ris, ri) |
| 584 | } |
| 585 | if len(errs) > 0 { |
| 586 | panic(errs) // this is how `v4` handles errors. `v5` has methods to have panic-free usage |
| 587 | } |
| 588 | return ris |
| 589 | } |
| 590 | |
| 591 | // Static registers a new route with path prefix to serve static files from the provided root directory. |
| 592 | func (e *Echo) Static(pathPrefix, fsRoot string, middleware ...MiddlewareFunc) RouteInfo { |