PathMatch class

Represents the result of matching a request path against a compiled PathPattern in Jetleaf.

Contains information about whether the match succeeded, any extracted path variables, the original path segments, and the pattern used.

Example

final match = PathMatch(
  matches: true,
  variables: {'id': '42'},
  segments: ['api', 'users', '42'],
  path: '/api/users/42',
  pattern: '/api/users/{id}',
);

if (match.matches) {
  final userId = match.getVariable('id'); // '42'
}

See also

Constructors

PathMatch({required bool matches, required Map<String, String> variables, required List<String> segments, required String path, required String pattern, Map<String, dynamic> metadata = const {}})
Creates a new PathMatch result.
const
PathMatch.noMatch(String path, String pattern)
Creates a PathMatch representing a failed match.
factory

Properties

hashCode → int
The hash code for this object.
no setterinherited
matches → bool
Whether the path successfully matches the pattern.
final
metadata → Map<String, dynamic>
Additional metadata associated with the match.
final
path → String
The full path string that was matched.
final
pattern → String
The pattern string that was matched against.
final
runtimeType → Type
A representation of the runtime type of the object.
no setterinherited
segments → List<String>
The raw segments of the matched path, split by /.
final
variables → Map<String, String>
Map of extracted variable names to their values.
final

Methods

getVariable(String name) → String?
Get a variable value by name.
getVariableNames() → Iterable<String>
Get all variable names.
noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() → String
A string representation of this object.
override

Operators

operator ==(Object other) → bool
The equality operator.
inherited