Pattern Matching — Aquilia Documentation
Comprehensive guide and documentation for Pattern Matching in the Aquilia framework. View API reference, examples, and implementation patterns.
Routing Pattern Matching Syntax Aquilia employs a formal parameter parser that validates and casts incoming path and query parameter tokens. Legacy Syntax Removed Angle brackets/chevrons (e.g. ) are no longer supported and have been completely removed. You must use curly braces "} for all routing parameters. Parameter Grammar Definition A parameter token follows this EBNF grammar structure: This design allows you to enforce validation constraints, type-casting rules, and string transformations directly within the route template. Segment Type Reference Type Name Internal Regex Matcher Casting Result -[a-fA-F0-9] -4[a-fA-F0-9] -[89abAB][a-fA-F0-9] -[a-fA-F0-9] ', 'str (validated UUID v4)'], ['slug', '[a-z0-9-]+', 'str'], ['bool', '(true|false|1|0|yes|no)', 'bool'], ['json', '[^/]+', 'Parsed JSON object/list'] ].map(([type_, regex, casting], i) => ( name: "} ))} Constraints & ReDoS Prevention Constraints are defined by appending pipeline operators (|) to parameter declarations: min=value / max=value: Restricts numeric limits or character lengths. in=(value1,value2): Limits choices to a static set (enum validation). re="pattern": Matches a custom regular expression constraint. ReDoS Security Guard: Custom regular expression constraints are automatically analyzed for vulnerability before compile time. Patterns exceeding 256 characters or patterns using unsafe nested quantifiers (like (a+)+) are rejected immediately to protect against Denial of Service. Splats & Optional Groups Splats capture all remaining segments. Optional groups allow nested, optional sub-segments: Query Parameters & Transforms Declare query variables directly at the end of templates. Use transforms (prefixed by @) to modify parameters on-the-fly: Routing Overview URL Generation )
Go to Homepage