Spaces:
Sleeping
Sleeping
| pub mod accounts; | |
| pub mod config; | |
| pub mod proxy; | |
| use axum::{Router, routing::{get, post, delete}}; | |
| /// Create API routes (without state for management endpoints) | |
| pub fn api_routes<S>() -> Router<S> | |
| where | |
| S: Clone + Send + Sync + 'static, | |
| { | |
| Router::new() | |
| // Account management | |
| .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)) | |
| // Configuration management | |
| .route("/api/config", get(config::load_config)) | |
| .route("/api/config", post(config::save_config)) | |
| // Proxy management | |
| .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)) | |
| // Health check | |
| .route("/api/health", get(health_check)) | |
| } | |
| /// Health check endpoint | |
| async fn health_check() -> axum::Json<serde_json::Value> { | |
| axum::Json(serde_json::json!({ | |
| "status": "ok", | |
| "version": env!("CARGO_PKG_VERSION") | |
| })) | |
| } | |