httpCorsHandler function
Implementation
void httpCorsHandler(bool? enabled, HttpRequest req) {
CORSConfig cors = Dox().config.cors;
if (enabled ?? cors.enabled) {
Map<String, dynamic> headers = <String, dynamic>{
HttpHeaders.accessControlAllowOriginHeader: cors.origin,
HttpHeaders.accessControlAllowMethodsHeader: cors.methods,
HttpHeaders.accessControlAllowHeadersHeader: cors.headers,
HttpHeaders.accessControlExposeHeadersHeader: cors.exposeHeaders,
HttpHeaders.accessControlAllowCredentialsHeader: cors.credentials,
HttpHeaders.accessControlMaxAgeHeader: cors.maxAge,
};
headers.forEach((String key, dynamic value) {
_setCorsValue(req.response, key, value);
});
}
}