api

Miscellaneous JSON/HTML API endpoints that are not tied to a single domain.

struct RenderMarkdownBody

source

pub struct RenderMarkdownBody

Request body for the render-markdown endpoint, sent as a form.

The form also carries the _csrf field, which the CSRF layer checks before this handler runs; serde ignores it.

Field Type Description
body String Raw Markdown source to render.

Implements Deserialize<'de>.

fn api_render_markdown

source

pub async fn api_render_markdown(Form(payload): Form<RenderMarkdownBody>) -> Response

POST /api/render-markdown — render Markdown to HTML.

The editor’s live preview posts the draft as an application/x-www-form-urlencoded body with a body field and the _csrf field, read from the page’s csrf-token meta tag, so the CSRF layer accepts it.

Parameter Type Description
Form(payload) Form<RenderMarkdownBody> the form holding the Markdown source
returns Response A 200 response with the rendered HTML as text/html; charset=utf-8. The Form extractor rejects a body that is not a form with a body field before the handler runs.