Installation
To get started with warp
, you need to add it to your project's Cargo.toml
file. Since warp
is built on Tokio, you'll also need the tokio
crate.
Dependencies
Add warp
and tokio
to your [dependencies]
in Cargo.toml
:
tokio = { version = "1", features = ["full"] }
warp = { version = "0.4", features = ["server"] }
The server
feature is required to run a standalone warp
server using warp::serve()
.
Feature Flags
warp
is designed to be modular. You can enable or disable features to control which functionalities are included, helping to keep your binary size small and compile times fast. The v0.4.0
release made many features optional.
Here are the available feature flags defined in Cargo.toml
:
server
: Enables thewarp::serve()
function and related utilities to run a standalone hyper server. This is the most common way to run awarp
application.test
: Enables thewarp::test
module, which provides utilities for testing your filters without running a full server.multipart
: Enables support formultipart/form-data
requests. This feature adds themulter
dependency.websocket
: Enables WebSocket support viawarp::ws
. This addstokio-tungstenite
and related dependencies.compression
: A meta-feature that enables both gzip and brotli compression filters.compression-gzip
: Enablesgzip
anddeflate
compression filters. This adds theasync-compression
dependency withdeflate
andgzip
features.compression-brotli
: Enablesbrotli
compression filter. This adds theasync-compression
dependency with thebrotli
feature.
Example: Enabling Multiple Features
If you need WebSockets and multipart forms, your Cargo.toml
would look like this:
warp = { version = "0.4", features = ["server", "websocket", "multipart"] }