diff --git a/contrib/src/json/mod.rs b/contrib/src/json/mod.rs index 89e2e7c5..5d94aae3 100644 --- a/contrib/src/json/mod.rs +++ b/contrib/src/json/mod.rs @@ -88,13 +88,16 @@ impl FromData for JSON { } } +// Serializes the wrapped value into JSON. Returns a response with Content-Type +// JSON and a fixed-size body with the serialization. If serialization fails, an +// `Err` of `Status::InternalServerError` is returned. impl Responder<'static> for JSON { fn respond(self) -> response::Result<'static> { serde_json::to_string(&self.0).map(|string| { content::JSON(string).respond().unwrap() }).map_err(|e| { error_!("JSON failed to serialize: {:?}", e); - Status::BadRequest + Status::InternalServerError }) } } diff --git a/contrib/src/templates/mod.rs b/contrib/src/templates/mod.rs index 3029047b..7c03ea74 100644 --- a/contrib/src/templates/mod.rs +++ b/contrib/src/templates/mod.rs @@ -25,10 +25,10 @@ use rocket::http::{ContentType, Status}; /// /// Templating in Rocket words by first discovering all of the templates inside /// the template directory. The template directory is configurable via the -/// `template_dir` configuration parameter. The path set in `template_dir` -/// should be relative to the Rocket configuration file. See the [configuration -/// chapter](https://rocket.rs/guide/configuration) of the guide for more -/// information on configuration. +/// `template_dir` configuration parameter and defaults to `templates/`. The +/// path set in `template_dir` should be relative to the Rocket configuration +/// file. See the [configuration chapter](https://rocket.rs/guide/configuration) +/// of the guide for more information on configuration. /// /// Templates are discovered according to their extension. At present, this /// library supports the following templates and extensions: