Module rocket::response::content

source ·
Expand description

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

§Usage

Each type wraps a given responder. The Responder implementation of each type replaces the Content-Type of the wrapped responder and delegates the remainder of the response to the wrapped responder. This allows for setting the Content-Type of a type that doesn’t set it itself or for overriding one that does.

§Example

The following snippet creates an Html content response for a string. Normally, raw strings set their response Content-Type to text/plain. By using the Html content response, the Content-Type will be set to text/html instead.

use rocket::response::content;

let response = content::Html("<h1>Hello, world!</h1>");

Structs§

  • Sets the Content-Type of a Responder to a chosen value.
  • Override the Content-Type of the response to CSS , or text/css .
  • Override the Content-Type of the response to HTML , or text/html .
  • Override the Content-Type of the response to JavaScript , or application/javascript .
  • Override the Content-Type of the response to JSON , or application/json .
  • Override the Content-Type of the response to MessagePack , or application/msgpack .
  • Override the Content-Type of the response to plain text , or text/plain .
  • Override the Content-Type of the response to XML , or text/xml .