35 lines
885 B
Rust
35 lines
885 B
Rust
|
|
pub mod anthropic;
|
||
|
|
pub mod assets;
|
||
|
|
pub mod chat;
|
||
|
|
pub mod context;
|
||
|
|
pub mod fs;
|
||
|
|
pub mod health;
|
||
|
|
pub mod model;
|
||
|
|
pub mod payloads;
|
||
|
|
pub mod project;
|
||
|
|
pub mod rest;
|
||
|
|
pub mod search;
|
||
|
|
pub mod shell;
|
||
|
|
pub mod ws;
|
||
|
|
|
||
|
|
use crate::http::context::AppContext;
|
||
|
|
use crate::http::rest::build_openapi_service;
|
||
|
|
use poem::EndpointExt;
|
||
|
|
use poem::{Route, get};
|
||
|
|
|
||
|
|
pub fn build_routes(ctx: AppContext) -> impl poem::Endpoint {
|
||
|
|
let ctx_arc = std::sync::Arc::new(ctx);
|
||
|
|
|
||
|
|
let (api_service, docs_service) = build_openapi_service(ctx_arc.clone());
|
||
|
|
|
||
|
|
Route::new()
|
||
|
|
.nest("/api", api_service)
|
||
|
|
.nest("/docs", docs_service.swagger_ui())
|
||
|
|
.at("/ws", get(ws::ws_handler))
|
||
|
|
.at("/health", get(health::health))
|
||
|
|
.at("/assets/*path", get(assets::embedded_asset))
|
||
|
|
.at("/", get(assets::embedded_index))
|
||
|
|
.at("/*path", get(assets::embedded_file))
|
||
|
|
.data(ctx_arc)
|
||
|
|
}
|