Expand description
Contains types that set the Content-Type of a response.
§Usage
Each type in this module is a Responder that wraps an existing
Responder, overwriting the Content-Type of the response but otherwise
delegating the response to the wrapped responder. As a convenience,
(ContentType, R) where R: Responder is also a Responder that
overrides the Content-Type to the value in .0:
use rocket::http::ContentType;
#[get("/")]
fn index() -> (ContentType, &'static str) {
(ContentType::HTML, "Is this HTML? <p>Sure, why not!</p>")
}§Example
The following snippet creates a RawHtml response from a string. Normally,
raw strings set their response Content-Type to text/plain. By using the
RawHtml content response, the Content-Type will be set to text/html
instead:
use rocket::response::content;
let response = content::RawHtml("<h1>Hello, world!</h1>");Structs§
- RawCss
- Override the
Content-Typeof the response to CSS , or text/css . - RawHtml
- Override the
Content-Typeof the response to HTML , or text/html . - RawJava
Script - Override the
Content-Typeof the response to JavaScript , or application/javascript . - RawJson
- Override the
Content-Typeof the response to JSON , or application/json . - RawMsg
Pack - Override the
Content-Typeof the response to MessagePack , or application/msgpack . - RawText
- Override the
Content-Typeof the response to plain text , or text/plain . - RawXml
- Override the
Content-Typeof the response to XML , or text/xml .