Please check the build logs for more information.
See Builds for ideas on how to fix a failed build, or Metadata for how to configure docs.rs builds.
If you believe this is docs.rs' fault, open an issue.
oxify-server
Production-ready HTTP server foundation for OxiFY, built on Axum and Tower.
Overview
oxify-server provides a robust, batteries-included HTTP server runtime for building LLM workflow APIs. It handles the operational concerns (logging, tracing, graceful shutdown, middleware) so you can focus on building workflow endpoints.
Ported from: OxiRS - Battle-tested in production semantic web applications.
Features
- Axum Framework: Modern, ergonomic async web framework
- Tower Middleware: Composable middleware stack
- Graceful Shutdown: Signal handling (SIGINT, SIGTERM)
- Request Tracing: Automatic request ID generation and propagation
- Structured Logging: Integration with tracing ecosystem
- CORS Support: Configurable cross-origin resource sharing
- Compression: Gzip, Brotli, Deflate (optional feature)
- Authentication: Built-in JWT middleware integration
- Production-Ready: Comprehensive configuration and error handling
Installation
[]
= { = "../crates/api/oxify-server" }
# Or with features
= { = "../crates/api/oxify-server", = ["compression", "cors"] }
Feature Flags
compression(default): HTTP response compression (gzip, brotli, deflate)cors(default): CORS middleware support
Quick Start
Basic Server
use ;
use ;
use json;
async
With Authentication
use ;
use ;
use ;
use Arc;
async
async
async
async
Core Components
ServerRuntime
Main server runtime that manages the Axum server lifecycle.
ServerConfig
Server configuration with sensible defaults.
Development Config:
- Host:
127.0.0.1 - Port:
3000 - Request logging: enabled
- CORS: enabled (all origins)
- Compression: enabled
Production Config:
- Host:
0.0.0.0 - Port:
8080 - Request logging: enabled
- CORS: disabled (configure manually)
- Compression: enabled
- Graceful shutdown: 30s timeout
Middleware
Request ID Middleware
Automatically adds a unique request ID to each request.
use request_id_middleware;
let app = new
.route
.layer;
Request ID is available in:
- Response header:
x-request-id - Request extensions:
request.extensions().get::<RequestId>()
Logging Middleware
Logs request/response details with structured tracing.
use logging_middleware;
let app = new
.route
.layer;
Logs include:
- Method and path
- Status code
- Duration
- Request ID
Authentication Middleware
JWT-based authentication middleware.
use auth_middleware;
use JwtManager;
use Arc;
let jwt_manager = new;
let app = new
.route
.layer;
Public routes (skip authentication):
/health/metrics/login/register
CORS Middleware
Cross-origin resource sharing configuration.
use cors_layer;
let app = new
.route
.layer;
Default CORS settings:
- Allow all origins (development)
- Allow methods: GET, POST, PUT, DELETE, OPTIONS
- Allow headers: Content-Type, Authorization
- Max age: 3600 seconds
Complete Example
use ;
use ;
use ;
use ;
use Arc;
use Level;
async
async
async
Graceful Shutdown
The server automatically handles shutdown signals:
# Send SIGINT (Ctrl+C)
# Send SIGTERM
Shutdown sequence:
- Stop accepting new connections
- Wait for active requests to complete (up to timeout)
- Force shutdown after timeout
Configure timeout:
let config = ServerConfig ;
Production Deployment
Docker
FROM rust:1.75 as builder
WORKDIR /app
COPY . .
RUN cargo build --release
FROM debian:bookworm-slim
COPY --from=builder /app/target/release/oxify-api /usr/local/bin/
EXPOSE 8080
CMD ["oxify-api"]
Environment Variables
# Server configuration
# Authentication
# Database
Kubernetes
apiVersion: apps/v1
kind: Deployment
metadata:
name: oxify-api
spec:
replicas: 3
selector:
matchLabels:
app: oxify-api
template:
metadata:
labels:
app: oxify-api
spec:
containers:
- name: oxify-api
image: oxify/api:latest
ports:
- containerPort: 8080
env:
- name: OXIFY_HOST
value: "0.0.0.0"
- name: OXIFY_PORT
value: "8080"
- name: JWT_SECRET
valueFrom:
secretKeyRef:
name: oxify-secrets
key: jwt-secret
livenessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 10
periodSeconds: 30
readinessProbe:
httpGet:
path: /health
port: 8080
initialDelaySeconds: 5
periodSeconds: 10
Monitoring
Health Check Endpoint
use ;
let app = new
.route;
async
Metrics (Future)
Integration with Prometheus metrics is planned:
use metrics_middleware;
let app = new
.route
.layer;
// Exposes /metrics endpoint with:
// - http_requests_total
// - http_request_duration_seconds
// - http_requests_in_flight
Testing
Run the test suite:
# Run with all features
Performance
- Startup time: <100ms
- Request overhead: <1ms (middleware processing)
- Graceful shutdown: <30s (configurable)
- Concurrent connections: Limited by Tokio runtime (default: CPU cores * 2)
Dependencies
Core dependencies:
axum- Web frameworktower/tower-http- Middlewaretokio- Async runtimetracing- Structured logging
Integration:
oxify-authn- Authentication middlewareoxify-authz- Authorization (future)
License
Apache-2.0
Attribution
Ported from OxiRS with permission. Original implementation by the OxiLabs team.