refactor: move routes under /tori/ prefix and add /api/obj mount

Routes now live at /tori/api, /ws/tori, and static files at /tori/.
Root / redirects to /tori/. Object storage mounted at /api/obj.
Dev proxy updated accordingly.
This commit is contained in:
Fam Zheng
2026-03-04 11:46:52 +00:00
parent 84779a0527
commit ae72e699f4
5 changed files with 40 additions and 7 deletions

View File

@@ -5,7 +5,9 @@ mod kb;
mod llm;
mod exec;
pub mod state;
mod template;
mod timer;
mod tools;
mod ws;
use std::sync::Arc;
@@ -19,6 +21,7 @@ pub struct AppState {
pub config: Config,
pub agent_mgr: Arc<agent::AgentManager>,
pub kb: Option<Arc<kb::KbManager>>,
pub obj_root: String,
}
#[derive(Debug, Clone, serde::Deserialize)]
@@ -83,17 +86,28 @@ async fn main() -> anyhow::Result<()> {
// Resume incomplete workflows after restart
resume_workflows(database.pool.clone(), agent_mgr.clone()).await;
let obj_root = std::env::var("OBJ_ROOT").unwrap_or_else(|_| "/data/obj".to_string());
let state = Arc::new(AppState {
db: database,
config: config.clone(),
agent_mgr: agent_mgr.clone(),
kb: kb_arc,
obj_root: obj_root.clone(),
});
let app = Router::new()
.nest("/api", api::router(state))
.nest("/ws", ws::router(agent_mgr))
.fallback_service(ServeDir::new("web/dist").fallback(ServeFile::new("web/dist/index.html")))
.nest("/tori/api", api::router(state))
.nest("/api/obj", api::obj::router(obj_root.clone()))
.route("/api/obj/", axum::routing::get({
let r = obj_root;
move || api::obj::root_listing(r)
}))
.nest("/ws/tori", ws::router(agent_mgr))
.nest_service("/tori", ServeDir::new("web/dist").fallback(ServeFile::new("web/dist/index.html")))
.route("/", axum::routing::get(|| async {
axum::response::Redirect::permanent("/tori/")
}))
.layer(CorsLayer::permissive());
let addr = format!("{}:{}", &config.server.host, config.server.port);