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 host = RequestParts.of(request).headers['host'];
  if (host == null || host.isEmpty) {
    // HTTP/1.1 requires it, so its absence is a malformed request rather
    // than a missing optional value.
    return const Err(Rejection.badRequest('the Host header is required'));
  }
  return Ok(host);
}