Module rocket::response::status

source ·
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