mirror of
https://wget.la/https://github.com/leookun/cursor-byok
synced 2026-12-01 01:05:10 +08:00
34 lines
666 B
Rust
34 lines
666 B
Rust
use axum::{
|
|
extract::{Path, Query, State},
|
|
Json,
|
|
};
|
|
use serde::Deserialize;
|
|
|
|
use crate::Result;
|
|
|
|
use super::{CallDetail, CallSummary, ControlService};
|
|
|
|
#[derive(Deserialize)]
|
|
pub struct CallQuery {
|
|
#[serde(default = "default_limit")]
|
|
limit: i64,
|
|
}
|
|
|
|
pub async fn list(
|
|
State(service): State<ControlService>,
|
|
Query(query): Query<CallQuery>,
|
|
) -> Result<Json<Vec<CallSummary>>> {
|
|
Ok(Json(service.calls(query.limit).await?))
|
|
}
|
|
|
|
pub async fn detail(
|
|
State(service): State<ControlService>,
|
|
Path(call_id): Path<String>,
|
|
) -> Result<Json<CallDetail>> {
|
|
Ok(Json(service.call(&call_id).await?))
|
|
}
|
|
|
|
fn default_limit() -> i64 {
|
|
100
|
|
}
|