Module rocket::response [] [src]

Types and traits to build and send responses.

The return type of a Rocket handler can be any type that implements the Responder trait. Among other things, this module contains several such types.

Composing

Many of the built-in Responder types chain responses: they take in another Responder and add, remove, or change information in the response. In other words, many Responder types are built to compose well. As a result, you'll often have types of the form A<B<C>> consisting of three Responders A, B, and C. This is normal and encouraged as the type names typically illustrate the intended response.

Contrib

The contrib crate contains several useful Responders including Template and JSON.

Modules

content

Contains types that set the Content-Type of a response.

status

Contains types that set the status code and correspoding headers of a response.

Structs

Content

Sets the Content-Type of a Responder to a chosen value.

Failure

A failing response; simply forwards to the catcher for the given Status.

Flash

Sets a "flash" cookie that will be removed when it is accessed. The anologous request type is FlashMessage.

NamedFile

A file with an associated name; responds with the Content-Type based on the file extension.

Redirect

An empty redirect response to a given URL.

Response

An HTTP/Rocket response, returned by Responders.

ResponseBuilder

Type for easily building Responses.

Stream

Streams a response to a client from an arbitrary Reader type.

Enums

Body

The body of a response: can be sized or streamed/chunked.

Constants

DEFAULT_CHUNK_SIZE

The default size, in bytes, of a chunk for streamed responses.

Traits

Responder

Trait implemented by types that generate responses for clients.

Type Definitions

Result

Type alias for the Result of a Responder::respond call.