class Athena::Routing::Response
inherits Reference
#
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
Class methods#
.new(content : String? = nil, status : HTTP::Status | Int32 = HTTP::Status::OK, headers : HTTP::Headers = HTTP::Headers.new)
#
(content : String? = 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.
Methods#
#last_modified : Time?
#
: Time?
Returns a Time
representing the last-modified
header if set, otherwise nil
.
#last_modified=(time : Time? = nil) : Nil
#
(time : Time? = nil) : Nil
Updates the last-modified
header to the provided time.
Removes the header if time is nil
.
#send(context : HTTP::Server::Context) : Nil
#
(context : HTTP::Server::Context) : Nil
Sends self
to the client based on the provided context.
How the content gets written can be customized via an ART::Response::Writer
.
#set_etag(etag : String? = nil, weak : Bool = false) : Nil
#
(etag : String? = nil, weak : Bool = false) : Nil
Updates the etag
header to the provided, optionally weak, etag.
Removes the header if etag is nil
.
#set_public : Nil
#
: Nil
Marks self
as "public".
Adds the public
cache-control
directive and removes the private
directive.