(
State(runtime): State<DashboardRuntime>,
AxumPath(project_id): AxumPath<String>,
)
| 164 | } |
| 165 | |
| 166 | pub(crate) async fn context( |
| 167 | State(runtime): State<DashboardRuntime>, |
| 168 | AxumPath(project_id): AxumPath<String>, |
| 169 | ) -> (StatusCode, Json<Value>) { |
| 170 | let Some(db) = GlobalDb::open().await else { |
| 171 | return ( |
| 172 | StatusCode::SERVICE_UNAVAILABLE, |
| 173 | Json(json!({ |
| 174 | "status": "missing_registry", |
| 175 | "project": null, |
| 176 | "aliases": [], |
| 177 | "stores": [], |
| 178 | })), |
| 179 | ); |
| 180 | }; |
| 181 | let Some(context) = db.project_registry_context_by_id(&project_id).await else { |
| 182 | return ( |
| 183 | StatusCode::NOT_FOUND, |
| 184 | Json(json!({ |
| 185 | "status": "not_found", |
| 186 | "project": null, |
| 187 | "aliases": [], |
| 188 | "stores": [], |
| 189 | })), |
| 190 | ); |
| 191 | }; |
| 192 | let is_active = Some(project_id.as_str()) == runtime.active_project_id(); |
| 193 | ( |
| 194 | StatusCode::OK, |
| 195 | Json(json!({ |
| 196 | "status": "ok", |
| 197 | "is_active": is_active, |
| 198 | "project": context.project, |
| 199 | "aliases": context.aliases, |
| 200 | "stores": context.stores, |
| 201 | })), |
| 202 | ) |
| 203 | } |
| 204 | |
| 205 | #[cfg(test)] |
| 206 | mod tests { |
nothing calls this directly
no test coverage detected