ResponseContext class
Provides access to the current HTTP response within a request processing zone.
This class enables services and controllers to access the current response without having to pass it as a parameter through the call chain.
Key features:
- Zone-based response storage and retrieval
- Response header management shortcuts
- Content type helpers
- Response timing and profiling
Constructors
Properties
- 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
-
toString(
) → String -
A string representation of this object.
inherited
Operators
-
operator ==(
Object other) → bool -
The equality operator.
inherited
Static Properties
Static Methods
-
cacheControl(
String value) → void - Set Cache-Control header
-
contentTypeHtml(
) → void - Set Content-Type to HTML
-
contentTypeJson(
) → void - Set Content-Type to JSON
-
contentTypeText(
) → void - Set Content-Type to plain text
-
contentTypeXml(
) → void - Set Content-Type to XML
-
cors(
{String allowOrigin = '*', String allowMethods = 'GET, POST, PUT, DELETE, OPTIONS', String allowHeaders = 'Content-Type, Authorization'}) → void - Set CORS headers
-
header(
String name, String value) → void - Add a response header
-
html(
String html) → void - Send an HTML response
-
json(
Map< String, dynamic> data) → void - Send a JSON response
-
noCache(
) → void - Set no-cache headers
-
redirect(
String url, {int status = 302}) → Future< void> - Send a redirect response
-
status(
int code) → void - Set the response status code
-
text(
String text) → void - Send a plain text response