1 unstable release
Uses new Rust 2024
| 0.1.0 | Sep 30, 2025 |
|---|
#694 in HTTP server
202 downloads per month
37KB
825 lines
A compatibility library for running Warp filters within Axum servers.
This crate enables gradual migration from Warp to Axum by allowing existing Warp routes to run alongside new Axum routes in the same server.
Example
use axum::{routing::get, Router};
use warpdrive::WarpService;
use warp::Filter;
// Existing Warp routes
let warp_routes = warp::path("api")
.and(warp::get())
.map(|| "Hello from Warp!")
.boxed();
// Combine with Axum routes
let app: Router = Router::new()
.route("/", get(|| async { "Hello from Axum!" }))
.fallback_service(WarpService::new(warp_routes));
Limitations
- WebSockets are not supported, these should be migrated to Axum first.
- Some other advanced Warp features may not work.
- Some conversion overhead from converting
http::Requestandhttp::Responsetypes.
Error Handling
WarpService acts as a transparent wrapper. The existing Warp rejection handling should work
exactly as before. It merely converts the pre-v1.0 http::Response into the Axum 0.8-compatible
v1.0 http::Response type.
The service only adds 500 errors in the extremely rare case of HTTP format conversion failures.
warpdrive
A compatibility library for running Warp filters within Axum servers, enabling gradual migration from Warp to Axum. warpdrive is based on warp v0.3 and will not work for warp v0.4 or higher.
Usage
Add to your Cargo.toml:
[dependencies]
warpdrive = "0.1.0"
axum = "0.8"
warp = "0.3"
Example
use axum::{routing::get, Router};
use warpdrive::WarpService;
use warp::Filter;
#[tokio::main]
async fn main() {
// Existing Warp routes
let warp_routes = warp::path("api")
.and(warp::get())
.map(|| "Hello from Warp!")
.boxed();
// New Axum routes
let app = Router::new()
.route("/", get(|| async { "Hello from Axum!" }))
.fallback_service(WarpService::new(warp_routes));
let listener = tokio::net::TcpListener::bind("0.0.0.0:3000").await.unwrap();
axum::serve(listener, app).await.unwrap();
}
Dependencies
~10–22MB
~280K SLoC