| pub mod accounts; |
| pub mod config; |
| pub mod proxy; |
|
|
| use axum::{Router, routing::{get, post, delete}}; |
|
|
| |
| pub fn api_routes<S>() -> Router<S> |
| where |
| S: Clone + Send + Sync + 'static, |
| { |
| Router::new() |
| |
| .route("/api/accounts", get(accounts::list_accounts)) |
| .route("/api/accounts", post(accounts::add_account)) |
| .route("/api/accounts/:id", delete(accounts::delete_account)) |
| .route("/api/accounts/:id/quota", post(accounts::refresh_quota)) |
| .route("/api/accounts/refresh-all", post(accounts::refresh_all_quotas)) |
| .route("/api/accounts/current", get(accounts::get_current_account)) |
| .route("/api/accounts/:id/set-current", post(accounts::set_current_account)) |
|
|
| |
| .route("/api/config", get(config::load_config)) |
| .route("/api/config", post(config::save_config)) |
|
|
| |
| .route("/api/proxy/status", get(proxy::get_proxy_status)) |
| .route("/api/proxy/mapping", post(proxy::update_model_mapping)) |
| .route("/api/proxy/restart", post(proxy::restart_proxy)) |
| .route("/api/proxy/generate-key", post(proxy::generate_api_key)) |
|
|
| |
| .route("/api/health", get(health_check)) |
| } |
|
|
| |
| async fn health_check() -> axum::Json<serde_json::Value> { |
| axum::Json(serde_json::json!({ |
| "status": "ok", |
| "version": env!("CARGO_PKG_VERSION") |
| })) |
| } |
|
|