MCPcopy Index your code
hub / github.com/labstack/echo / Match

Method Match

echo.go:569–589  ·  view source on GitHub ↗

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)

Source from the content-addressed store, hash-verified

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.
569func (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.
592func (e *Echo) Static(pathPrefix, fsRoot string, middleware ...MiddlewareFunc) RouteInfo {

Callers 3

TestGroup_MatchFunction · 0.45
TestEchoMatchFunction · 0.45

Calls 1

AddRouteMethod · 0.95

Tested by 3

TestGroup_MatchFunction · 0.36
TestEchoMatchFunction · 0.36