forked from coracle/caravel
18 lines
440 B
Rust
18 lines
440 B
Rust
use std::sync::Arc;
|
|
|
|
use axum::extract::{Path, State};
|
|
|
|
use crate::api::Api;
|
|
use crate::web::{ApiResult, not_found, ok};
|
|
|
|
pub async fn list_plans(State(api): State<Arc<Api>>) -> ApiResult {
|
|
ok(api.query.list_plans())
|
|
}
|
|
|
|
pub async fn get_plan(State(api): State<Arc<Api>>, Path(id): Path<String>) -> ApiResult {
|
|
match api.query.get_plan(&id) {
|
|
Some(plan) => ok(plan),
|
|
None => Err(not_found("plan not found")),
|
|
}
|
|
}
|