Skip to main content

Module http

Module http 

Source
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 to addr
  • routes sub-module — individual handler functions for each endpoint
  • AppState — 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.