polaris_app
Shared HTTP server runtime for Polaris products. Provides an axum-based server that integrates with the Polaris plugin lifecycle.
Quick Start
use Server;
use ;
let mut server = new;
server.add_plugins;
// Add other plugins that register routes...
server.finish; // Server starts listening on ready()
Adding Routes
Any plugin that depends on AppPlugin can register routes via the HttpRouter API:
use ;
use Server;
use ;
use ;
;
Multiple plugins can register routes independently -- they are all merged before the server starts.
HttpIOProvider
HttpIOProvider lives in polaris_sessions::http (its only consumer). It
bridges HTTP requests to agent UserIO via tokio channels:
use HttpIOProvider;
use ;
use Arc;
let = new;
// Pre-load user input from HTTP request body
// input_tx.send(IOMessage::user_text("hello")).await;
// Wrap as UserIO for the agent
// let user_io = UserIO::new(Arc::new(provider));
// Collect agent output for HTTP response
// let response = output_rx.recv().await;
Configuration
use AppConfig;
new
.with_host // Default: 127.0.0.1
.with_port // Default: 3000
.with_cors_origin
.with_cors_origin;
Empty CORS origins (default) allows any origin.
Middleware
Applied automatically to all routes:
| Layer | Description |
|---|---|
| Request ID | Injects UUID x-request-id header on every request |
| Tracing | Logs request/response spans via tracing |
| CORS | Configurable allowed origins, methods, headers |
| Propagate | Copies x-request-id to response headers |
Dependencies
| Crate | Purpose |
|---|---|
polaris_system |
Plugin trait, Server, GlobalResource, API |
polaris_core_plugins |
IOProvider trait, IOMessage types |
axum |
HTTP framework |
tower-http |
CORS, tracing, request ID middleware |
tokio |
Async runtime, channels, networking |