CorsHandler class
Pre-built CORS (Cross-Origin Resource Sharing) middleware handler.
- Inheritance
-
- Object
- MockHttpServerMiddleware
- CorsHandler
Constructors
-
CorsHandler({List<
String> allowedOrigins = const ['*'], List<String> allowedMethods = const ['GET', 'POST', 'PUT', 'DELETE', 'OPTIONS', 'PATCH'], List<String> allowedHeaders = const ['Content-Type', 'Authorization', 'X-Requested-With'], bool allowCredentials = true}) -
Creates a CorsHandler middleware configurations.
const
Properties
- allowCredentials → bool
-
Permits credential tokens across domains.
final
-
allowedHeaders
→ List<
String> -
Accepted request header fields.
final
-
allowedMethods
→ List<
String> -
Permitted HTTP action verbs.
final
-
allowedOrigins
→ List<
String> -
Whitelisted origins. Defaults to '*' (allow all).
final
- hashCode → int
-
The hash code for this object.
no setterinherited
- runtimeType → Type
-
A representation of the runtime type of the object.
no setterinherited
Methods
-
noSuchMethod(
Invocation invocation) → dynamic -
Invoked when a nonexistent method or property is accessed.
inherited
-
onRequest(
RecordedRequest request) → Future< RecordedRequest> -
Invoked before the server dispatcher processes the
request. Returns the request (possibly modified) to proceed, or throws a MiddlewareResponseException to short-circuit and return that response immediately.override -
onResponse(
RecordedRequest request, MockResponse response) → Future< MockResponse> -
Invoked after the dispatcher resolves the response, but before it is sent to the client.
Allows transforming the resolved
responseor injecting custom headers.override -
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited