handle method
Processes the incoming request and optionally invokes next to continue the middleware pipeline.
To pass execution down the chain, await next and return its resulting BloomResponse.
To short-circuit execution (e.g. authentication rejection), return a BloomResponse directly
without calling next.
Implementation
@override
Future<BloomResponse?> handle(
BloomRequest request, BloomNextFunction next) async {
final response = await next();
response.headers['access-control-allow-origin'] = allowOrigin;
if (allowCredentials) {
response.headers['access-control-allow-credentials'] = 'true';
}
if (request.method == 'OPTIONS') {
response.headers['access-control-allow-methods'] = allowMethods;
response.headers['access-control-allow-headers'] = allowHeaders;
}
return response;
}