extract method
Produces the value, or the rejection that stops the handler.
Implementation
@override
Future<Result<T, Rejection>> extract(Request request) async {
final raw = pathParametersOf(request)[key];
if (raw == null) {
return Err(Rejection.badRequest('path parameter "$key" is missing'));
}
final String decoded;
try {
decoded = Uri.decodeComponent(raw);
} on ArgumentError {
return Err(
Rejection.badRequest(
'path parameter "$key" is not valid percent-encoding',
),
);
}
return coerce<T>(decoded, source: 'path parameter "$key"');
}