extract method

  1. @override
Future<Result<T, Rejection>> extract(
  1. Request request
)
override

Produces the value, or the rejection that stops the handler.

Implementation

@override
Future<Result<T, Rejection>> extract(Request request) async {
  final raw = request.headers[name.toLowerCase()];
  if (raw == null) {
    if (null is T) return Ok(null as T);
    return Err(Rejection.badRequest('header "$name" is required'));
  }
  return coerce<T>(raw, source: 'header "$name"');
}