Skip to main content

Crate spikard

Crate spikard 

Source
Expand description

High-level Rust API for Spikard.

This crate provides the ergonomic App interface that mirrors the batteries-included experience available in the Python/Node/Ruby bindings. Routes, DTO schemas, and advanced transports (WebSocket/SSE) are all backed by the shared spikard-http runtime, ensuring identical validation and middleware behaviour across languages.

Re-exports§

pub use upload::UploadFile;

Modules§

testing
Testing utilities for Spikard applications.
upload
File upload handling for multipart/form-data requests.
validation
JSON-RPC and request validation utilities.

Structs§

ApiKeyConfig
API Key authentication configuration
App
Spikard application builder.
BackgroundJobError
BackgroundJobMetadata
BackgroundTaskConfig
Configuration for in-process background task execution.
CompressionConfig
Compression configuration shared across runtimes
CorsConfig
CORS configuration for a route
FullSchemaConfig
Configuration for fully-featured schemas with Query, Mutation, and Subscription types
GraphQLRouteConfig
Configuration for GraphQL routes
GraphQLSubscriptionSnapshot
Snapshot of a GraphQL subscription exchange over WebSocket.
GrpcConfig
Configuration for gRPC support
JsonRpcConfig
JSON-RPC server configuration
JsonRpcMethodInfo
JSON-RPC method metadata for routes that support JSON-RPC
JwtConfig
JWT authentication configuration
OpenApiConfig
OpenAPI configuration
ProblemDetails
RFC 9457 Problem Details for HTTP APIs
QueryMutationConfig
Configuration for schemas with Query and Mutation types
QueryOnlyConfig
Configuration for schemas with only Query type
RateLimitConfig
Rate limiting configuration shared across runtimes
RequestContext
Wrapper around the raw request and validated metadata.
Response
HTTP Response with custom status code, headers, and content
ResponseSnapshot
Snapshot of an Axum response used by higher-level language bindings.
Route
Route definition with compiled validators
RouteBuilder
Builder for defining a route.
RouteMetadata
Route metadata extracted from bindings
SchemaConfig
Configuration for GraphQL schema building.
ServerConfig
Server configuration
SseEvent
An individual SSE event
StaticFilesConfig
Static file serving configuration
TestClient
Core test client for making HTTP requests to a Spikard application.
WebSocketConnection
WebSocket connection wrapper for testing.

Enums§

AppError
Error type for application builder operations.
HandlerResponse
Unified response type that can represent either a ready response or a streaming body.
HookResult
Result of a lifecycle hook execution
Method
HTTP method
SnapshotError
Possible errors while converting an Axum response into a snapshot.
WebSocketMessage
A WebSocket message that can be text or binary.

Traits§

IntoHandler
Convert user-facing handler functions into the low-level Handler trait.
LifecycleHook
Trait for lifecycle hooks on native targets (Send + Sync, Send futures).
SseEventProducer
SSE event producer trait
WebSocketHandler
WebSocket message handler trait

Functions§

add_cors_headers
Add CORS headers to a successful response
delete
Convenience helper for building a DELETE route.
get
Convenience helper for building a GET route.
handle_preflight
Handle CORS preflight (OPTIONS) request
patch
Convenience helper for building a PATCH route.
post
Convenience helper for building a POST route.
put
Convenience helper for building a PUT route.
request_hook
Create a request hook for the current target.
response_hook
Create a response hook for the current target.
validate_cors_request
Validate a non-preflight CORS request

Type Aliases§

HandlerResult
Result type for handlers
LifecycleHooks
LifecycleHooksBuilder