oxidite-core
Core HTTP server and routing for the Oxidite web framework.
Overview
oxidite-core provides the foundational building blocks for the Oxidite web framework, including the HTTP server, router, request/response types, and type-safe extractors. It serves as the base layer upon which all other Oxidite components are built.
Installation
Add this to your Cargo.toml:
[]
= "0.1"
= { = "1", = ["full"] }
Features
- HTTP/1.1 and HTTP/2 support - Built on top of
hyperfor high-performance HTTP handling - WebSocket support - Built-in WebSocket functionality
- Type-safe extractors - Safe and ergonomic request data extraction
- Flexible routing - Support for path parameters, wildcards, and complex routing patterns
- Middleware support - Integration with the
towerecosystem - Async-first - Designed with Rust's async/await from the ground up
Usage
Basic Server
use ;
async
Using Extractors
oxidite-core provides several type-safe extractors for handling different kinds of requests:
use ;
use ;
// JSON extractor
async
// Query parameters extractor
async
// Path parameters extractor
async
// Form data extractor
async
// Cookies extractor
async
// Raw body extractor
async
Advanced Routing
use ;
let mut router = new;
// Basic routes
router.get;
router.post;
router.put;
router.delete;
// Path parameters
router.get;
// Wildcard routes (should be registered last)
router.get;
Response Utilities
oxidite-core provides convenient response utilities:
use Response;
// Text response
let text_response = text;
// JSON response
let json_response = json;
// HTML response
let html_response = html;
// Custom status code
let custom_response = builder
.status // I'm a teapot
.body;
Error Handling
The framework provides comprehensive error handling with appropriate HTTP status codes:
use Error;
// Various error types
let not_found_error = NotFound;
let bad_request_error = BadRequest;
let forbidden_error = Forbidden;
let conflict_error = Conflict;
License
MIT