/api/status, for Homepage's dashboard (#67)
The iPX tile on Homepage was a bare link: nothing in ipx gave a summary a customapi widget could read. /api/status serves what `ipx status` prints (feeds, items pending, files downloaded), from the same function the control socket answers with, plus the version. It sits behind sign-in like the rest of /api; Homepage sends the shared [web] token as the ipx_token cookie. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
17
src/web.rs
17
src/web.rs
@@ -52,6 +52,7 @@ pub fn router(state: WebState) -> Router {
|
||||
.route("/api/fetch", post(fetch_now))
|
||||
.route("/api/opml", get(export_opml).post(import_opml))
|
||||
.route("/api/settings", get(get_settings).patch(patch_settings))
|
||||
.route("/api/status", get(status))
|
||||
.route("/api/popular", get(get_popular))
|
||||
.route("/api/directory", get(get_directory))
|
||||
.route("/api/popular/{id}", post(subscribe_popular))
|
||||
@@ -1808,6 +1809,22 @@ async fn import_opml(
|
||||
Ok(Json(serde_json::json!({ "added": added, "already": already })))
|
||||
}
|
||||
|
||||
/// The numbers `ipx status` prints, and the version, for a dashboard such as Homepage's
|
||||
/// customapi widget. Behind sign-in like the rest of /api; Homepage sends the shared token.
|
||||
async fn status(State(state): State<WebState>) -> Response {
|
||||
match crate::status(&state.ctx).await {
|
||||
Event::Status { feeds, pending, downloaded } => Json(serde_json::json!({
|
||||
"feeds": feeds,
|
||||
"pending": pending,
|
||||
"downloaded": downloaded,
|
||||
"version": env!("CARGO_PKG_VERSION"),
|
||||
}))
|
||||
.into_response(),
|
||||
Event::Error { msg } => (StatusCode::INTERNAL_SERVER_ERROR, msg).into_response(),
|
||||
_ => StatusCode::INTERNAL_SERVER_ERROR.into_response(),
|
||||
}
|
||||
}
|
||||
|
||||
#[derive(Serialize)]
|
||||
struct Settings {
|
||||
schedule: String,
|
||||
|
||||
Reference in New Issue
Block a user