diff options
Diffstat (limited to 'src/api/dashboard/mod.rs')
| -rw-r--r-- | src/api/dashboard/mod.rs | 15 |
1 files changed, 15 insertions, 0 deletions
diff --git a/src/api/dashboard/mod.rs b/src/api/dashboard/mod.rs index 7a643d0..3a50ca6 100644 --- a/src/api/dashboard/mod.rs +++ b/src/api/dashboard/mod.rs @@ -509,6 +509,7 @@ pub(crate) fn router(state: AppState) -> Router<AppState> { "/admin/dashboard/messages/own/events", get(own_messages_events), ) + .route("/admin/dashboard/messages/own/{seq}", get(own_message)) .layer(Extension(Hub::new(state, closing))) } @@ -573,6 +574,20 @@ impl Drop for Watching { } } +/// `GET /admin/dashboard/messages/own/{seq}`: the message `seq` of this node's +/// (`messages/own/events`, which leaves it out) written out, `{"text": …}`, for a page +/// subscribed to this node showing it; `404` once it isn't kept any more (the latest +/// 1000, while someone looks). +async fn own_message( + Extension(hub): Extension<Arc<Hub>>, + axum::extract::Path(seq): axum::extract::Path<u64>, +) -> axum::response::Response { + match hub.state.traffic.log.text_of(seq) { + Some(text) => axum::Json(json!({ "text": text })).into_response(), + None => super::error_response(axum::http::StatusCode::NOT_FOUND, "not kept any more", None), + } +} + /// `GET /admin/dashboard/messages/own/events`: server-sent events, `messages` with the /// messages this node sent and received since the last, as they come (gathered for /// `MESSAGES_GATHERED` after the first), as the page's own `messages` events have them, |
