Documentation
    Preparing search index...

    Class Route<Controller>

    The route class exposes the APIs for constructing a route using the fluent API.

    Type Parameters

    • Controller extends Constructor<any> = any

    Hierarchy

    • default
      • Route
    Index

    Constructors

    • Creates a new Route instance

      Type Parameters

      • Controller extends Constructor<any> = any

      Parameters

      • app: Application<any>

        The AdonisJS application instance

      • routerMiddleware: ParsedGlobalMiddleware[]

        Array of global middleware registered on the router

      • options: {
            pattern: string;
            methods: string[];
            handler:
                | string
                | RouteFn
                | [
                    Controller
                    | LazyImport<Controller>,
                    GetControllerHandlers<Controller>?,
                ];
            globalMatchers: RouteMatchers;
        }

        Configuration options for the route

      Returns Route<Controller>

    Methods

    • Define matcher for a given param. If a matcher exists, then we do not override that, since the routes inside a group will set matchers before the group, so they should have priority over the group matchers.

      Route.group(() => {
      Route.get('/:id', 'handler').where('id', /^[0-9]$/)
      }).where('id', /[^a-z$]/)

      The /^[0-9]$/ will win over the matcher defined by the group

      Parameters

      Returns this

    • Define prefix for the route. Calling this method multiple times applies multiple prefixes in the reverse order.

      Parameters

      • prefix: string

        The prefix to add to the route

      Returns this

      Current Route instance for method chaining

    • Define a custom domain for the route. We do not overwrite the domain unless overwrite flag is set to true.

      Parameters

      • domain: string
      • overwrite: boolean = false

      Returns this

    • Give a unique name to the route. Assinging a new unique removes the existing name of the route.

      Setting prepends to true prefixes the name to the existing name.

      Parameters

      • name: string
      • prepend: boolean = false

      Returns this

    • Mark route as deleted. Deleted routes are not registered with the route store

      Returns void

    • Set the route pattern

      Parameters

      • pattern: string

      Returns this