1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#![deny(warnings)]
use warp::Filter;
#[tokio::main]
async fn main() {
let file = warp::path("todos").and(warp::fs::file("./examples/todos.rs"));
let dir = warp::path("ws_chat").and(warp::fs::file("./examples/websockets_chat.rs"));
let file_and_dir = warp::get()
.and(file.or(dir))
.with(warp::compression::gzip());
let examples = warp::path("ex")
.and(warp::fs::dir("./examples/"))
.with(warp::compression::deflate());
let routes = file_and_dir.or(examples);
warp::serve(routes).run(([127, 0, 0, 1], 3030)).await;
}