1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
//! The Inertia v3 protocol header constants.
//!
//! Single source of truth for the header names this module recognizes.
use axum::http::HeaderName;
/// Grouping type carrying the protocol `HeaderName` constants.
pub(crate) struct Headers;
impl Headers {
/// `X-Inertia` — request: `true` marks an Inertia request; response: `true`
/// marks an Inertia JSON page response.
pub const INERTIA: HeaderName = HeaderName::from_static("x-inertia");
/// `X-Inertia-Version` — the client's current asset version (GET only);
/// echoed on a version-mismatch `409`.
pub const VERSION: HeaderName = HeaderName::from_static("x-inertia-version");
/// `X-Inertia-Partial-Component` — the component a partial reload targets.
pub const PARTIAL_COMPONENT: HeaderName =
HeaderName::from_static("x-inertia-partial-component");
/// `X-Inertia-Partial-Data` — comma-separated prop keys to include.
pub const PARTIAL_DATA: HeaderName = HeaderName::from_static("x-inertia-partial-data");
/// `X-Inertia-Partial-Except` — comma-separated prop keys to exclude.
pub const PARTIAL_EXCEPT: HeaderName = HeaderName::from_static("x-inertia-partial-except");
/// `X-Inertia-Reset` — comma-separated prop paths to reset.
pub const RESET: HeaderName = HeaderName::from_static("x-inertia-reset");
/// `X-Inertia-Error-Bag` — names the error bag to scope validation errors.
pub const ERROR_BAG: HeaderName = HeaderName::from_static("x-inertia-error-bag");
/// `X-Inertia-Except-Once-Props` — comma-separated *once keys* the client
/// already holds. The server withholds those values and still emits their
/// `onceProps` entries; the client fills them back in from its own copy.
pub const EXCEPT_ONCE_PROPS: HeaderName =
HeaderName::from_static("x-inertia-except-once-props");
/// `X-Inertia-Infinite-Scroll-Merge-Intent` — `prepend` when the client is
/// loading the previous page of an infinite scroll, `append` for the next.
pub const MERGE_INTENT: HeaderName =
HeaderName::from_static("x-inertia-infinite-scroll-merge-intent");
/// `X-Inertia-Location` — on a `409`, the destination for a full
/// `window.location` visit (external redirect or version mismatch).
pub const LOCATION: HeaderName = HeaderName::from_static("x-inertia-location");
/// `X-Inertia-Redirect` — on a `409`, the full redirect URL (including
/// fragment) for a fragment redirect; the client makes a fresh Inertia GET.
pub const REDIRECT: HeaderName = HeaderName::from_static("x-inertia-redirect");
/// `Purpose` — `prefetch` on prefetch visits.
pub const PURPOSE: HeaderName = HeaderName::from_static("purpose");
/// `Vary` — the standard HTTP `Vary` header, merged with `X-Inertia`.
pub const VARY: HeaderName = HeaderName::from_static("vary");
}
/// Well-known protocol header *values*.
pub(crate) struct Values;
impl Values {
/// The literal `X-Inertia` value sent by the official client.
pub const INERTIA_TRUE: &str = "true";
/// `Purpose: prefetch` — sent on prefetch visits.
pub const PURPOSE_PREFETCH: &str = "prefetch";
/// Merge intent for the *previous* side of an infinite scroll.
pub const MERGE_INTENT_PREPEND: &str = "prepend";
/// Merge intent for the *next* side of an infinite scroll.
pub const MERGE_INTENT_APPEND: &str = "append";
}