Response class

Represents an outgoing HTTP response from the Kronix framework.

Constructors

Response({int statusCode = 200, dynamic body, Map<String, String>? headers, List<String>? cookies})
Constructs a new Response with an optional body and headers.
Response.html(String html, {int status = 200})
Creates an HTML response with the provided html string and status code.
Response.json(dynamic data, {int status = 200})
Creates a JSON response with the provided data and status code.
Response.ok(dynamic body)
Response.redirect(String url, {int status = 302})

Properties

body → dynamic
The payload of the response, usually a String or null.
final
cookies List<String>
no setter
hashCode int
The hash code for this object.
no setterinherited
headers Map<String, String>
The HTTP headers to be sent with the response.
final
runtimeType Type
A representation of the runtime type of the object.
no setterinherited
statusCode int
The HTTP status code of the response (e.g., 200, 404, 500).
final

Methods

noSuchMethod(Invocation invocation) → dynamic
Invoked when a nonexistent method or property is accessed.
inherited
toString() String
A string representation of this object.
inherited
withCookie(String cookie) Response
Adds a cookie to the response.
withHeaders(Map<String, String> additionalHeaders) Response
Creates a copy of this response with additional/replaced headers.

Operators

operator ==(Object other) bool
The equality operator.
inherited