spikard-core
Shared transport-agnostic primitives and types for building Spikard runtimes across multiple languages and frameworks.
Status & Badges
Overview
spikard-core provides the foundational types and traits that enable Spikard to work across multiple language bindings:
- Request/Response models - HTTP-agnostic request and response types
- Validation primitives - JSON Schema validation and header/cookie checking
- Middleware interfaces - Traits for composable middleware stacks
- Serialization support - Efficient serialization via serde
- Error handling - Structured error types for cross-language error translation
Features
- Transport-agnostic - Works with Axum, Hyper, or any HTTP framework
- Schema validation - Built-in JSON Schema support via jsonschema crate
- Compression - Gzip and Brotli compression/decompression
- Header/Cookie handling - RFC-compliant header and cookie parsing
- URL encoding - Query string parsing and URL handling
- Zero-copy design - Efficient memory usage with minimal allocations
- Type safety - Strongly-typed request and response structures
Installation
[]
= "0.10.1"
= { = "1.0", = ["derive"] }
= "1.0"
Optional Features
[]
= { = "0.10.1", = ["di"] }
di- Enables dependency injection support with Tokio async runtime
Quick Start
Request/Response Handling
use ;
use HashMap;
// Create a request
let mut request = new;
// Add headers
request.headers_mut.insert;
// Add query parameters
let mut query = new;
query.insert;
request.set_query_params;
// Create a response
let mut response = new;
response.set_body;
Schema Validation
use ValidateBody;
use json;
let schema = json!;
let body = json!;
// Validate body against schema
validate_body?;
Compression Support
use compression;
let original = b"This is a long string that will be compressed";
// Gzip compression
let compressed = gzip_encode?;
let decompressed = gzip_decode?;
// Brotli compression
let compressed = brotli_encode?;
let decompressed = brotli_decode?;
Core Types
Request- HTTP request model with headers, cookies, body, and path parametersResponse- HTTP response model with status, headers, and bodyHandlerResult- Standard result type for handlersValidationError- Structured validation errors with field-level detailsRequestContext- Request execution context with metadataRouteConfig- Route configuration with validation schemas
Architecture
spikard-core sits at the foundation of the Spikard architecture:
┌─────────────────────────────────────┐
│ Language Bindings │
│ (Python, Node, Ruby, PHP, WASM) │
└──────────────┬──────────────────────┘
│ implements
┌──────────────▼──────────────────────┐
│ spikard-http (Axum Runtime) │
└──────────────┬──────────────────────┘
│ uses
┌──────────────▼──────────────────────┐
│ spikard-core (Primitives) │
└─────────────────────────────────────┘
All language bindings depend on spikard-core to ensure consistent request/response handling across platforms.
Documentation
Related Crates
- spikard - High-level HTTP framework
- spikard-http - HTTP server implementation
- spikard-py - Python bindings
- spikard-node - Node.js bindings
License
MIT