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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
//! Combined public-DID fallback that walks each compiled-in method's
//! resolver in priority order (T25).
//!
//! At compile time the daemon may have `method-webvh`, `method-web`,
//! both, or (in the future) neither. Each enabled method's
//! `dispatch(state, parts)` is called in turn; the first method that
//! recognises the URL returns its response, and we stop there. If no
//! method matches, the fallback returns 404 (or, in the daemon's
//! combined router, hands off to the SPA static handler).
//!
//! ## Priority
//!
//! 1. **did:webvh** (when `method-webvh` is on). Webvh's URLs end in
//! `/did.jsonl` or `/did-witness.json`; both are method-exclusive,
//! so registering webvh first doesn't shadow other methods.
//! 2. **did:webs** (when `method-webs` is on). `/keri.cesr` is
//! method-exclusive, but `/did.json` is **not** — did:web serves it
//! too. So webs must come before web, and it claims a `did.json`
//! only when the stored record is actually a did:webs record,
//! returning `None` otherwise. Ordering them the other way round
//! would let did:web's bridge answer for a did:webs slot: it would
//! look for a webvh log where a CESR stream is stored, and 404 a
//! DID that is hosted perfectly well.
//! 3. **did:web** (when `method-web` is on). Web's URL ends in
//! `/did.json`. Last, so it acts as the fall-through for that
//! suffix — which is what its did:webvh bridge has always been.
//!
//! ## Why a fallback rather than `Router::route("/{*x}/did.jsonl", ...)`
//!
//! Axum's nested catch-alls (`/{*path}`) don't compose with sibling
//! catch-alls at the same level — you get a "match" conflict at
//! router-build time. The fallback path is the only way to do
//! suffix-based dispatch in a single router. Each method's
//! `dispatch` does its own suffix check and returns `None` when the
//! URL isn't its problem, which is structurally equivalent to "this
//! route didn't match, try the next one".
use ;
use StatusCode;
use ;
use resolve_web;
use resolve_webs;
use resolve_webvh;
use crateAppState;
/// Combined fallback handler: walks each enabled method's dispatcher
/// in priority order, returning the first match.
///
/// 404 when no method recognises the URL. Callers expecting an SPA
/// (daemon mode) check for 404 and then call the static handler.
pub async