feat: frontend routes (just the index html file for now)

This commit is contained in:
2026-10-18 15:31:19 -04:00
parent 3be16d3d58
commit 692a1a56a7
4 changed files with 33 additions and 1 deletions

18
Cargo.lock generated
View File

@@ -1645,6 +1645,7 @@ dependencies = [
"serde_with", "serde_with",
"strum", "strum",
"tokio", "tokio",
"tower-http 0.7.1",
"tracing", "tracing",
"tracing-subscriber", "tracing-subscriber",
"typed-builder", "typed-builder",
@@ -2127,7 +2128,7 @@ dependencies = [
"tokio-rustls", "tokio-rustls",
"tokio-util", "tokio-util",
"tower", "tower",
"tower-http", "tower-http 0.6.11",
"tower-service", "tower-service",
"url", "url",
"wasm-bindgen", "wasm-bindgen",
@@ -2860,6 +2861,21 @@ dependencies = [
"url", "url",
] ]
[[package]]
name = "tower-http"
version = "0.7.1"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "08a05a66a4fdd61cbbe0a1d755ffe0ca6aba159dd4820936a0ff8a8278245b9c"
dependencies = [
"bitflags 2.13.2",
"bytes",
"http",
"percent-encoding",
"pin-project-lite",
"tower-layer",
"tower-service",
]
[[package]] [[package]]
name = "tower-layer" name = "tower-layer"
version = "0.3.3" version = "0.3.3"

View File

@@ -28,6 +28,7 @@ serde_json = "1.0.151"
serde_with = "3.24.0" serde_with = "3.24.0"
strum = { version = "0.28.0", features = ["derive"] } strum = { version = "0.28.0", features = ["derive"] }
tokio = { version = "1.53.1", features = ["macros", "rt-multi-thread"] } tokio = { version = "1.53.1", features = ["macros", "rt-multi-thread"] }
tower-http = { version = "0.7.1", features = ["cors"] }
tracing = "0.1.44" tracing = "0.1.44"
tracing-subscriber = { version = "0.3.23", features = ["env-filter"] } tracing-subscriber = { version = "0.3.23", features = ["env-filter"] }
typed-builder = "0.23.2" typed-builder = "0.23.2"

11
src/server/frontend.rs Normal file
View File

@@ -0,0 +1,11 @@
use axum::response::Html;
use axum_extra::routing::TypedPath;
use serde::Deserialize;
#[derive(Deserialize, TypedPath)]
#[typed_path("/")]
pub struct IndexPath;
pub async fn spa(_: IndexPath) -> Html<&'static str> {
Html(include_str!("index.html"))
}

View File

@@ -6,11 +6,13 @@ use rand::Rng;
use rand::RngExt; use rand::RngExt;
use secrecy::SecretString; use secrecy::SecretString;
use std::sync::Arc; use std::sync::Arc;
use tower_http::cors::CorsLayer;
use typed_builder::TypedBuilder; use typed_builder::TypedBuilder;
use url::Url; use url::Url;
mod chat; mod chat;
mod decisions; mod decisions;
mod frontend;
mod embeddings; mod embeddings;
mod models; mod models;
mod system_one; mod system_one;
@@ -46,6 +48,8 @@ pub fn create_router() -> Router<AppState> {
.typed_post(embeddings::create_embeddings) .typed_post(embeddings::create_embeddings)
.typed_post(system_one::create_system_one) .typed_post(system_one::create_system_one)
.typed_get(models::list_models) .typed_get(models::list_models)
.typed_get(frontend::spa)
.layer(CorsLayer::new())
} }
pub fn create_app(state: AppState) -> Router<()> { pub fn create_app(state: AppState) -> Router<()> {