feat: add auto doc via utiopia
CI / Rust CI (push) Successful in 4m29s

This commit is contained in:
2026-04-10 15:45:41 +02:00
parent b3ad5249c0
commit a22560c337
10 changed files with 86 additions and 3 deletions
+12 -2
View File
@@ -1,16 +1,26 @@
pub mod chat;
pub mod models;
mod openapi;
use crate::auth::middleware::auth_middleware;
use crate::state::app_state::AppState;
use axum::{Router, middleware, routing::get, routing::post};
pub fn router() -> Router<AppState> {
fn public_router() -> Router<AppState> {
Router::new().route("/openapi.json", get(openapi::openapi_json))
}
pub fn protected_router() -> Router<AppState> {
Router::new()
.route("/models", get(models::list_models))
.route("/completions", post(chat::completions))
.route("/chat/completions", post(chat::chat_completions))
.route("/models/{model}/load", post(models::load_model))
.route("/models/{model}/unload", post(models::unload_model))
.layer(middleware::from_fn(auth_middleware))
}
pub fn router() -> Router<AppState> {
Router::new()
.merge(public_router())
.merge(protected_router().layer(middleware::from_fn(auth_middleware)))
}