vendor: update cargo-cxcloud-web-app-0.1.0

This commit is contained in:
cx-git-agent
2026-04-26 16:48:27 +00:00
committed by GitHub
parent da60a3a90f
commit 6b5a63697e
7 changed files with 2548 additions and 3 deletions
+7
View File
@@ -0,0 +1,7 @@
{
"git": {
"sha1": "927a31cbf65f78c3ef6b729631b2fc35335afe06",
"dirty": true
},
"path_in_vcs": "services/cxcloud-rs/crates/web-app"
}
Generated
+2391
View File
File diff suppressed because it is too large Load Diff
+61
View File
@@ -0,0 +1,61 @@
# THIS FILE IS AUTOMATICALLY GENERATED BY CARGO
#
# When uploading crates to the registry Cargo will automatically
# "normalize" Cargo.toml files for maximal compatibility
# with all versions of Cargo and also rewrite `path` dependencies
# to registry (e.g., crates.io) dependencies.
#
# If you are reading this file be aware that the original Cargo.toml
# will likely look very different (and much more reasonable).
# See Cargo.toml.orig for the original contents.
[package]
edition = "2021"
name = "cxcloud-web-app"
version = "0.1.0"
build = false
publish = ["cxai"]
autolib = false
autobins = false
autoexamples = false
autotests = false
autobenches = false
readme = false
[[bin]]
name = "web-app"
path = "src/main.rs"
[dependencies.anyhow]
version = "1"
[dependencies.axum]
version = "0.7"
features = ["macros"]
[dependencies.cxcloud-common]
version = "0.1.0"
registry-index = "sparse+https://git.cxllm-studio.com/api/packages/CxAI-LLM/cargo/"
[dependencies.serde]
version = "1"
features = ["derive"]
[dependencies.serde_json]
version = "1"
[dependencies.tokio]
version = "1"
features = ["full"]
[dependencies.tower-http]
version = "0.5"
features = [
"fs",
"cors",
"trace",
"timeout",
]
[dependencies.tracing]
version = "0.1"
+19
View File
@@ -0,0 +1,19 @@
[package]
name = "cxcloud-web-app"
version.workspace = true
edition.workspace = true
publish.workspace = true
[[bin]]
name = "web-app"
path = "src/main.rs"
[dependencies]
cxcloud-common = { workspace = true }
tokio = { workspace = true }
axum = { workspace = true }
serde = { workspace = true }
serde_json = { workspace = true }
tower-http = { workspace = true }
tracing = { workspace = true }
anyhow = { workspace = true }
-3
View File
@@ -1,3 +0,0 @@
# cargo-cxcloud-web-app-0.1.0
Cargo crate: cxcloud-web-app-0.1.0
+41
View File
@@ -0,0 +1,41 @@
mod routes;
use axum::Router;
use std::sync::Arc;
use tower_http::services::ServeDir;
use tracing::info;
use cxcloud_common::{
config::{env_or, env_port},
telemetry,
};
#[derive(Clone)]
pub struct AppState {
pub api_gateway_url: String,
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let otel_endpoint = env_or("OTEL_EXPORTER_OTLP_ENDPOINT", "http://localhost:4317");
let log_level = env_or("LOG_LEVEL", "info");
telemetry::init("web-app", &otel_endpoint, &log_level);
let api_gateway_url = env_or("API_GATEWAY_URL", "http://localhost:8080");
let static_dir = env_or("STATIC_DIR", "./static");
let state = Arc::new(AppState { api_gateway_url });
let app = Router::new()
.merge(routes::router(state))
.fallback_service(ServeDir::new(&static_dir));
let port = env_port("WEB_APP_PORT", 8090);
info!(port, static_dir, "Web app starting");
let listener = tokio::net::TcpListener::bind(format!("0.0.0.0:{port}")).await?;
axum::serve(listener, app).await?;
telemetry::shutdown();
Ok(())
}
+29
View File
@@ -0,0 +1,29 @@
use axum::{
extract::State,
response::Json,
routing::get,
Router,
};
use std::sync::Arc;
use cxcloud_common::health::HealthResponse;
use crate::AppState;
pub fn router(state: Arc<AppState>) -> Router {
Router::new()
.route("/health", get(health))
.route("/api/config", get(config))
.with_state(state)
}
async fn health() -> Json<HealthResponse> {
Json(HealthResponse::healthy("web-app"))
}
async fn config(State(state): State<Arc<AppState>>) -> Json<serde_json::Value> {
Json(serde_json::json!({
"api_gateway_url": state.api_gateway_url,
"version": env!("CARGO_PKG_VERSION"),
}))
}