Module rocket::response::status[][src]

Expand description

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

Responding

Types in this module designed to make it easier to construct correct responses with a given status code. Each type takes in the minimum number of parameters required to construct a correct response. Some types take in responders; when they do, the responder finalizes the response by writing out additional headers and, importantly, the body of the response.

The Custom type allows responding with any Status but does not ensure that all of the required headers are present. As a convenience, (Status, R) where R: Responder is also a Responder, identical to Custom.

use rocket::http::Status;

#[get("/")]
fn index() -> (Status, &'static str) {
    (Status::NotFound, "Hey, there's no index!")
}

Structs

Accepted

Sets the status of the response to 202 (Accepted).

BadRequest

Sets the status of the response to 400 (Bad Request).

Conflict

Sets the status of the response to 409 (Conflict).

Created

Sets the status of the response to 201 (Created).

Custom

Creates a response with the given status code and underlying responder.

Forbidden

Sets the status of the response to 403 (Forbidden).

NoContent

Sets the status of the response to 204 (No Content).

NotFound

Sets the status of the response to 404 (Not Found).

Unauthorized

Sets the status of the response to 401 (Unauthorized).