Debian Codegraph @

third_party/rust/warp/README.md

raw
1 # warp
2
3 [![crates.io](https://img.shields.io/crates/v/warp.svg)](https://crates.io/crates/warp)
4 [![Released API docs](https://docs.rs/warp/badge.svg)](https://docs.rs/warp)
5 [![MIT licensed](https://img.shields.io/badge/license-MIT-blue.svg)](./LICENSE)
6 [![GHA Build Status](https://github.com/seanmonstar/warp/workflows/CI/badge.svg)](https://github.com/seanmonstar/warp/actions?query=workflow%3ACI)
7 [![Discord chat][discord-badge]][discord-url]
8
9 A super-easy, composable, web server framework for warp speeds.
10
11 The fundamental building block of `warp` is the `Filter`: they can be combined
12 and composed to express rich requirements on requests.
13
14 Thanks to its `Filter` system, warp provides these out of the box:
15
16 * Path routing and parameter extraction
17 * Header requirements and extraction
18 * Query string deserialization
19 * JSON and Form bodies
20 * Multipart form data
21 * Static Files and Directories
22 * Websockets
23 * Access logging
24 * Gzip, Deflate, and Brotli compression
25
26 Since it builds on top of [hyper](https://hyper.rs), you automatically get:
27
28 - HTTP/1
29 - HTTP/2
30 - Asynchronous
31 - One of the fastest HTTP implementations
32 - Tested and **correct**
33
34 ## Example
35
36 Add warp and Tokio to your dependencies:
37
38 ```toml
39 tokio = { version = "1", features = ["full"] }
40 warp = "0.3"
41 ```
42
43 And then get started in your `main.rs`:
44
45 ```rust
46 use warp::Filter;
47
48 #[tokio::main]
49 async fn main() {
50 // GET /hello/warp => 200 OK with body "Hello, warp!"
51 let hello = warp::path!("hello" / String)
52 .map(|name| format!("Hello, {}!", name));
53
54 warp::serve(hello)
55 .run(([127, 0, 0, 1], 3030))
56 .await;
57 }
58 ```
59
60 For more information you can check the [docs](https://docs.rs/warp) or the [examples](https://github.com/seanmonstar/warp/tree/master/examples).
61
62 [discord-badge]: https://img.shields.io/discord/500028886025895936.svg?logo=discord
63 [discord-url]: https://discord.gg/RFsPjyt