netray-common
Shared utilities for the netray.info service ecosystem.
Modules
| Module | Purpose |
|---|---|
ip_extract |
Extract real client IP from proxy headers (CF-Connecting-IP, X-Real-IP, X-Forwarded-For) with trusted-proxy CIDR matching |
error |
Structured JSON error responses (ApiError trait + into_error_response) with Retry-After support |
rate_limit |
Keyed and global rate limiting wrappers around governor with metrics integration |
security_headers |
Axum middleware that sets CSP, HSTS, X-Frame-Options, and other security headers |
Usage
IP extraction
use IpExtractor;
let extractor = new.unwrap;
let client_ip = extractor.extract;
Error responses
use ;
// Produces: {"error": {"code": "...", "message": "..."}}
let response = into_error_response;
Rate limiting
use ;
let limiter: = keyed;
check_keyed_cost?;
Security headers
use ;
let layer_fn = security_headers_layer;
let app = new
.route
.layer;
MSRV
1.75
License
MIT