Router is interface for routing request contexts to registered routes.

Contract between Echo/Context instance and the router:

  - all routes must be added through methods on echo.Echo instance.
Reason: Echo instance uses RouteInfo.Params() length to allocate slice for paths parameters (see `Echo.contextPathParamAllocSize`).
- Router must populate Context during Router.Route call with:
- RoutableContext.SetPath
- RoutableContext.SetRawPathParams (IMPORTANT! with same slice pointer that c.RawPathParams() returns)
- RoutableContext.SetRouteInfo
And optionally can set additional information to Context with RoutableContext.Set

Hierarchy

  • Router

Indexable

[key: string]: any

Methods

  • Remove removes route from the Router

    Parameters

    • method: string
    • path: string

    Returns void

  • Route searches Router for matching route and applies it to the given context. In case when no matching method was not found (405) or no matching route exists for path (404), router will return its implementation of 405/404 handler function.

    Parameters

    Returns HandlerFunc

Generated using TypeDoc