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
103
104
105
106
107
108
//! `GET /projects` REST route over the `fs.list_projects` JSON-RPC method
//! (issue #3365).
//!
//! Why: the GUI's workstream-first project-picker modal needs a small,
//! read-only, loopback-only roster of candidate projects (ADR-0011 — this
//! daemon binds loopback only, matching every other route in this gateway).
//! Mirrors `super::fs`'s shape exactly: a thin handler over
//! `crate::fs_browse::protocol::list_projects` via [`super::respond`], never
//! duplicating the scan logic (`crate::fs_browse::roster::list_projects`) as
//! a bespoke axum handler — see `super` module docs' "forking the two
//! surfaces" rationale.
//! What: [`routes`] builds a standalone `axum::Router<()>` (its own
//! `ProjectsState` carrying just the `Arc<Router>`, `with_state`-erased
//! before return, mirroring `super::fs::FsState`) mapping `GET /projects` ->
//! `fs.list_projects`. No query params — the roster takes none.
//! `crate::serve::http::build_axum_router` merges this into the daemon's
//! main router alongside `POST /rpc`, `GET /health`, `GET /fs`, and the
//! other REST resource groups — `/projects` collides with none of them.
//! Test: `tests::*`.
use Arc;
use Router as AxumRouter;
use State;
use get;
use Value;
use crateRouter;
use ;
/// Shared axum state for the route in this module: just the JSON-RPC
/// router, mirroring `super::fs::FsState` — the handler goes through
/// [`super::respond`] rather than touching the filesystem directly.
/// Build the `GET /projects` route group.
///
/// Why: kept separate from `crate::serve::http::build_axum_router` so this
/// resource group is unit-testable via `tower::util::ServiceExt::oneshot` on
/// its own, exactly like every other `rest::*` group.
/// What: one `GET` route, `ProjectsState { router }`, `with_state`-erased to
/// `axum::Router<()>` so the caller can `.merge()` it alongside the other
/// resource groups into the daemon's main router.
/// Test: `tests::list_projects_returns_200_with_entries_array`.
/// `GET /projects` -> `fs.list_projects`.
///
/// Why: the REST entry point for the project-picker modal's roster fetch.
/// What: `200` with the `ProjectRoster` JSON (`{"entries": [...]}`) — the
/// underlying RPC method never returns a caller-facing error (see
/// `fs_browse::protocol::list_projects`'s docs), so this route has no
/// documented error path of its own beyond a lower-level dispatch failure.
/// Test: `tests::list_projects_returns_200_with_entries_array`.
async