docspec_http/mime.rs
1//! Centralized MIME type constants for the conversion API.
2//!
3//! These constants are bare MIME types — no parameters (no `charset=utf-8`,
4//! no `q=...`). The `Content-Type` and `Accept` parsers strip parameters
5//! before comparing against these values; the conversion handler appends
6//! `; charset=utf-8` when constructing response `Content-Type` headers.
7//!
8//! # Why one canonical home
9//!
10//! These strings appear in three places at runtime:
11//!
12//! 1. [`crate::mime_parser`] — validating `Content-Type` and negotiating `Accept`.
13//! 2. [`crate::metrics`] — as bounded label values for the `input_mime_type`
14//! and `output_mime_type` Prometheus labels.
15//! 3. Integration tests — asserting response shapes and error messages.
16//!
17//! Defining them once here eliminates the risk that the validator and the
18//! metrics layer disagree on what counts as a "supported" MIME.
19
20/// MIME type for `BlockNote` JSON output. The primary output type returned
21/// on success when the client did not request a different format.
22pub const MIME_BLOCKNOTE: &str = "application/vnd.docspec.blocknote+json";
23
24/// Accepted alias for the `BlockNote` output MIME (input-only on `Accept`;
25/// the server always returns [`MIME_BLOCKNOTE`] in its `Content-Type`).
26pub const MIME_BLOCKNOTE_ALIAS: &str = "application/vnd.blocknote+json";
27
28/// MIME type for DOCX input. Strict — accepted as `Content-Type` only when
29/// sent verbatim with no parameters (binary format; charset is meaningless).
30pub const MIME_DOCX: &str =
31 "application/vnd.openxmlformats-officedocument.wordprocessingml.document";
32
33/// MIME type for HTML. Accepted as both input `Content-Type` and output
34/// `Accept`; emitted as the response `Content-Type` when the HTML writer
35/// is selected.
36pub const MIME_HTML: &str = "text/html";
37
38/// MIME type for Markdown input. Accepted as `Content-Type` on
39/// `POST /conversion`.
40pub const MIME_MARKDOWN: &str = "text/markdown";
41
42/// MIME type for `oxa.dev` JSON output, emitted when the `oxa.dev` writer is
43/// selected.
44pub const MIME_OXA: &str = "application/vnd.oxa+json";
45
46/// MIME type for Pandoc native output, emitted when the Pandoc native writer
47/// is selected.
48pub const MIME_PANDOC_NATIVE: &str = "application/vnd.pandoc.native";