Overview
Route parameters allow you to capture dynamic segments from the URL and pass them to your route handlers. Parameters are automatically parsed and made available to your controllers.Defining Route Parameters
Curly Brace Syntax
Define parameters using curly braces{} in your route path:
Colon Syntax
Internally, Aeros converts curly brace syntax to colon syntax. You can also use colons directly:Both syntaxes work identically. The router automatically converts
{param} to :param during route parsing.Accessing Parameters in Controllers
Route parameters are automatically injected into controller methods based on parameter names:Multiple Parameters
When using multiple parameters, they are passed to the controller method in the order they appear in the route:Accessing Parameters in Closures
While controller methods receive parameters automatically, closures can access the current route’s parameters through the router:How Parameter Parsing Works
The router uses a sophisticated matching algorithm to extract parameters:- The route path is split into parts (tokens)
- Each parameter position is tracked using the
:prefix - During matching, the router compares URL parts with route parts
- Non-parameter parts must match exactly
- Parameter positions capture the corresponding URL segment
Example Matching Process
For the route/users/{userId}/posts/{postId}:
Subdomain Parameters
Aeros also supports subdomain routing with parameters:@ symbol to explicitly define subdomain routes:
Parameter Constraints
Currently, Aeros extracts all parameter values as strings. You should validate and cast parameter values in your controller:URI Part Matching
The router enforces strict URI part count matching:/users/{id}matches/users/123/users/{id}does NOT match/users/123/edit/users/{id}does NOT match/users
Next Steps
Middleware
Add middleware to validate and process route parameters
Route Groups
Organize routes with shared middleware and prefixes