Expand description
HTTP handler functions for the stargazer operational API.
Each handler is an async fn that takes axum extractors (State, Query,
Path) and returns either a JSON response or a StatusCode error. All
database errors are logged at warn level and surfaced to the caller as
500 Internal Server Error with a generic body โ the raw sqlx::Error
is never leaked because it may contain connection strings or schema
details that are useful to an attacker.
ยงResponse types
The handlers operate on database rows (ReflectorRow, ActivityRow,
StreamRow) but serialize trimmed *View structs over the wire. The
view structs intentionally omit columns that are operationally useless
to the HTTP consumer (raw audio_mp3 blobs, stream ids internal to the
capture pipeline, etc.) and rename fields to the JSON conventions the
operator dashboards expect.
ยงTime-window parsing
Query endpoints accept a since parameter of the form <n><unit> where
n is a positive integer and unit is s, m, h, or d. The helper
parse_since turns this into a DateTime<Utc> anchored at Utc::now().
A missing or unparseable value falls back to the endpoint-specific
default (documented per handler).
Structsยง
- Activity
Query ๐ - Query parameters for the
/api/reflectors/{callsign}/activityendpoint. - Activity
View ๐ - JSON view of one activity-log row.
- Connected
Node ๐View - JSON view of one connected-node row.
- Global
Activity ๐Query - Query parameters for the
/api/activityendpoint. - Health
Response ๐ - JSON response body for the
/healthendpoint. - Metrics
Response ๐ - JSON response body for the
/metricsendpoint. - Reflector
Query ๐ - Query parameters for the
/api/reflectorsendpoint. - Reflector
View ๐ - JSON view of one reflector row.
- Stream
Query ๐ - Query parameters for the
/api/streamsendpoint. - Stream
View ๐ - JSON view of one captured stream.
- Upload
Queue ๐Query - Query parameters for the
/api/upload-queueendpoint.
Constantsยง
- DEFAULT_
ACTIVITY_ ๐LIMIT - Default row cap for
/api/activitywhenlimitis missing. - DEFAULT_
ACTIVITY_ ๐WINDOW - Default time window for
/api/reflectors/{callsign}/activity. - DEFAULT_
REFLECTOR_ ๐WINDOW - Default time window for
/api/reflectorswhensinceis missing. - DEFAULT_
STREAM_ ๐LIMIT - Default row cap for
/api/streamswhenlimitis missing. - DEFAULT_
STREAM_ ๐WINDOW - Default time window for
/api/streams. - DEFAULT_
UPLOAD_ ๐LIMIT - Default row cap for
/api/upload-queuewhenlimitis missing. - MAX_
LIMIT ๐ - Maximum rows any query endpoint will return regardless of
limit.
Functionsยง
- clamp_
limit ๐ - Clamps a caller-provided row limit to the configured maximum.
- health ๐
GET /healthโ kubernetes liveness/readiness probe.- list_
activity ๐ GET /api/activityโ global activity feed across all reflectors.- list_
reflectors ๐ GET /api/reflectorsโ list active reflectors with status.- list_
streams ๐ GET /api/streamsโ query captured streams with filters.- metrics ๐
GET /metricsโ tier statistics snapshot.- parse_
duration_ ๐string - Parses a relative time string like
"1h"or"30m"into aDuration. - parse_
since ๐ - Turns a relative
sincestring into an absoluteDateTime<Utc>. - reflector_
activity ๐ GET /api/reflectors/{callsign}/activityโ recent activity for one reflector.- reflector_
nodes ๐ GET /api/reflectors/{callsign}/nodesโ nodes linked to a reflector.- tier3_
connect ๐ POST /api/tier3/connectโ manually promote a reflector to Tier 3.- tier3_
disconnect ๐ DELETE /api/tier3/{callsign}/{module}โ disconnect a Tier 3 session.- upload_
queue ๐ GET /api/upload-queueโ pending and failed uploads.