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
// githttp-fs
//
// Git-based Content Management System
// Copyright: 2026, Valerian Saliou <valerian@valeriansaliou.name>
// License: Mozilla Public License v2.0 (MPL v2.0)
//! The API root endpoint: an authenticated no-op.
//!
//! Clients (and deployment tooling) need a way to verify that their API key
//! is accepted before firing real traffic — without creating a tenant,
//! writing a file, or otherwise mutating anything. A `GET` on the API root
//! is that probe: it goes through the exact same Bearer-key middleware as
//! every other route, so a `200` proves the credential works end to end and
//! a `401` proves it does not. Nothing else is checked, which also makes it
//! a natural liveness probe for monitors that hold the key.
//!
//! The server root `/` itself is not part of the API: anything sent there
//! is redirected to `/v1` so that a caller who forgot the version prefix is
//! pointed at the right place instead of getting a bare 404.
use ;
use json;
use crateAppState;
/// GET / (relative to the `/v1` nest, i.e. `GET /v1`)
///
/// Responds `200` with the JSON body `{ "pong": true }` — JSON like every
/// other endpoint, so clients never need a special parser for this one
/// route. Reaching this handler at all means the API-key middleware already
/// accepted the request — the response carries nothing about tenants,
/// repositories, or server internals.
///
/// On a **replica** the body gains a `replica` object describing this node's
/// own replication state. That is the one thing a caller legitimately needs
/// from this route beyond "the key works": a client failing over between
/// nodes has to be able to tell whether the one it reached is current,
/// catching up, or cut off from its master. It is also the route the
/// read-only guard always lets through, so a node refusing every other
/// request can still explain itself.
///
/// A standalone server and a master answer exactly `{ "pong": true }`, as
/// they always have — the extra field appears only where it means something.
pub async
/// ANY /
///
/// Registered on the outer (unauthenticated) router: every request to the
/// bare server root, whatever its method, is answered with a `308 Permanent
/// Redirect` to `/v1`. 308 (rather than 301/302) so the method and body are
/// preserved across the redirect. No auth is required here — the response
/// carries nothing but the well-known API prefix, and the redirect target
/// enforces the API key itself.
pub async