Expand description
HTTP API server module for xcodeai.
This module provides a REST API so that xcodeai can be controlled programmatically — e.g. from 企业微信 (WeChat Work) bots, web UIs, or any HTTP client.
Architecture:
start_server(config, addr)— builds the axum Router and binds toaddrroutessub-module — individual handler functions for each endpointAppState— shared state passed to every handler (session store, etc.)
The server intentionally has NO authentication — xcodeai is a single-user local tool. CORS is enabled so a local web front-end can call the API from a browser without proxy configuration.
§Thread-safety note
rusqlite’s Connection uses RefCell internally and is therefore !Sync.
We wrap SessionStore inside tokio::sync::Mutex so it can be shared
across tokio tasks safely. Axum’s state type must be Send + Sync + 'static,
so the wrapping is:
Arc<AppState> where AppState { store: Mutex<SessionStore>, ... }
Every handler acquires .store.lock().await before touching the DB.
Modules§
- routes
- Route handlers for the xcodeai HTTP API.
Structs§
- AppState
- Shared state cloned into every request handler via axum
State<Arc<AppState>>.
Functions§
- start_
server - Start the HTTP API server and block until it exits.