class Athena::Routing::Response
- Athena::Routing::Response
- Reference
- Object
Overview
Represents an HTTP response that should be returned to the client.
Contains the content, status, and headers that should be applied to the actual HTTP::Server::Response.
This type is used to allow the content, status, and headers to be mutated by ART::Listeners before being returned to the client.
The #content is written all at once to the server response's IO.
Direct Known Subclasses
- Athena::Routing::BinaryFileResponse
- Athena::Routing::RedirectResponse
- Athena::Routing::StreamedResponse
Defined in:
response.crConstructors
-
.new(content : String | Nil = nil, status : HTTP::Status | Int32 = HTTP::Status::OK, headers : HTTP::Headers = HTTP::Headers.new)
Creates a new response with optional content, status, and headers arguments.
Instance Method Summary
-
#content : String
Returns the contents of this response.
-
#content=(content : String | Nil)
Sets the response content.
-
#etag : String | Nil
Returns the value of the
#etagheader if set, otherwisenil. -
#headers : HTTP::Headers
Returns the response headers of this response.
-
#last_modified : Time | Nil
Returns a
Timerepresenting thelast-modifiedheader if set, otherwisenil. -
#last_modified=(time : Time | Nil = nil) : Nil
Updates the
last-modifiedheader to the provided time. -
#send(context : HTTP::Server::Context) : Nil
Sends
selfto the client based on the provided context. -
#set_etag(etag : String | Nil = nil, weak : Bool = false) : Nil
Updates the
#etagheader to the provided, optionally weak, etag. -
#set_public : Nil
Marks
selfas "public". -
#status : HTTP::Status
Returns the
HTTP::Statusof this response. -
#status=(code : HTTP::Status | Int32) : Nil
Sets the
HTTP::Statusof this response. - #writer=(writer : ART::Response::Writer)
Constructor Detail
Creates a new response with optional content, status, and headers arguments.
Instance Method Detail
Returns a Timerepresenting the last-modified header if set, otherwise nil.
Updates the last-modified header to the provided time.
Removes the header if time is nil.
Sends self to the client based on the provided context.
How the content gets written can be customized via an ART::Response::Writer.
Updates the #etag header to the provided, optionally weak, etag.
Removes the header if etag is nil.
Marks self as "public".
Adds the public cache-control directive and removes the private directive.