Skip to content

Extend docs for RenderData. #65

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jul 15, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 15 additions & 0 deletions src/content/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -114,14 +114,29 @@ const REQUEST_ROUTE_PROPERTY_NAME: &str = "request-route";
const TARGET_MEDIA_TYPE_PROPERTY_NAME: &str = "target-media-type";

/// Data passed to handlebars templates and executables.
///
/// Fields serialize into kebab-case (e.g. `server_info` becomes `server-info`).
#[derive(Clone, Serialize)]
#[serde(rename_all = "kebab-case")]
pub struct RenderData<ServerInfo: Clone + Serialize> {
/// A hierarchial index of the content. This is serialized with the name
/// `/` (with handlebars escaping this looks like `[/].[foo/].bar`).
#[serde(rename = "/")]
pub index: ContentIndex,

/// Metadata about the server, such as its version.
pub server_info: ServerInfo,

/// The request [`Route`] that caused this content to be rendered, if any.
pub request_route: Option<Route>,

/// The best [`MediaType`] as determined by content negotiation. Rendering
/// must emit content in this media type.
pub target_media_type: Option<MediaType>,

/// An [HTTP `4xx` or `5xx` status code](https://datatracker.ietf.org/doc/html/rfc7231#section-6)
/// indicating that something went wrong. This will be set while rendering
/// content for the `--error-handler-route`.
pub error_code: Option<u16>,
}

Expand Down