class Athena::Routing::Response

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

Defined in:

response.cr

Constructors

Instance Method Summary

Constructor Detail

def self.new(status : HTTP::Status | Int32 = HTTP::Status::OK, headers : HTTP::Headers = HTTP::Headers.new, &block : IO -> Nil) : ART::StreamedResponse #

DEPRECATED Use ART::StreamedResponse.new instead. This will be removed in Athena 0.13.0.


[View source]
def self.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.


[View source]

Instance Method Detail

def content : String #

Returns the contents of this response.


[View source]
def content=(content : String | Nil) #

Sets the response content.


[View source]
def headers : HTTP::Headers #

Returns the response headers of this response.


[View source]
def status : HTTP::Status #

Returns the HTTP::Status of this response.


[View source]
def status=(code : HTTP::Status | Int32) : Nil #

Sets the status of this response.


[View source]
def write(output : IO) : Nil #

Writes the #content to the provided output.

How the output gets written can be customized via an ART::Response::Writer.


[View source]
def writer=(writer : ART::Response::Writer) #

[View source]