Assigning Groups and Routes
Assigning Groups
Application Level Groups
Application Level Groups (defined in the application Group Enumeration) are assigned in Route Enumerations using the Group Attribute; the parent parameter is an application Group Enumeration Case that defines the parent Group.
Group Attributes
If an attribute applies to all routes in a Group (either an Application Level Groups or routes in a Route Enumeration, e.g. middleware to be applied, an attribute, e.g. Middleware, can be used.
Group attributes are:
- Cors
Defines CORS middleware
- Host
Defines a host that the routes respond to.
- Middleware
Defines a middleware to apply the routes.
This attribute can also disable an ancestor group middleware by setting the
disableparameter tofalse.
Assigning Routes
Routes are assigned to actions using one of the HTTP Method Attributes or the Route attribute; these define the HTTP method(s) the route responds to, and take an instance of RouteInterface (a Route Enumeration Case) as a parameter which defines the pattern a route must match.
Route Parameters
If the route pattern has parameters, each parameter is defined by one of the Parameter Attributes:
- Alpha
Alpha defines an alphabetic string
- Alphanumeric
Alphanumeric defines an alphanumeric string
- Hex
Hex defines a hexadecimal number
- Id
Id defines a number greater than 0
- In
In defines a list of allowed values
- Numeric
Numeric defines a decimal number
- Pattern
Pattern defines a regex to match; use if none of the other parameter attributes are suitable
- Uuid
Uuid defines a Universally Unique Identifier
Other Method Attributes
Other attributes can be used to further configure a route, e.g. middleware to be applied:
- DefaultValue
Defines a default value for a parameter when the route does not contain a value.
- Fallback
A fallback route that is attempted if no other routes in a group match. Only one fallback route is permitted in a group.
- Host
Defines the host(s) the route applies to.
- Middleware
Defines middleware(s) to apply the route.
This attribute can also disable group or class level middleware by setting the
disableparameter tofalse.- Override
Overrides a route with the same name.