extract method
Produces the value, or the rejection that stops the handler.
Implementation
@override
Future<Result<PeerInfo, Rejection>> extract(Request request) async {
final info = request.context[contextKey];
if (info is PeerInfo) return Ok(info);
if (info is HttpConnectionInfo) {
return Ok(
PeerInfo(
remoteAddress: info.remoteAddress.address,
remotePort: info.remotePort,
localPort: info.localPort,
),
);
}
return const Err(
Rejection.internal('connection information is unavailable'),
);
}