extract method

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

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

Implementation

@override
Future<Result<String, Rejection>> extract(Request request) async {
  final value = CookieJar.of(request)[name];
  if (value == null || value.isEmpty) {
    return Err(
      Rejection.unauthorized(
        'expected a $name cookie',
        challenge: 'Cookie',
      ),
    );
  }
  return Ok(value);
}