-
Notifications
You must be signed in to change notification settings - Fork 157
/
mount.rs
29 lines (23 loc) · 894 Bytes
/
mount.rs
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
#[macro_use] extern crate nickel;
use nickel::{Nickel, Mountable, StaticFilesHandler};
#[tokio::main]
async fn main() {
let mut server = Nickel::new();
/*
* Requests to /t should not end up in this route. Expected output for
* a request to /test/a is /a.
*/
server.mount("/test/", middleware! { |req|
format!("Got request with uri = '{}'", req.origin.uri())
});
/*
* Fall-through behaviour, if StaticFilesHandler does not find a matching file,
* the request uri must be reset so that it can be matched against other middleware.
*/
server.mount("/static/files/", StaticFilesHandler::new("examples/assets/"));
server.mount("/static/files/", middleware! { |req|
let path = req.path_without_query();
format!("No static file with path '{}'!", path)
});
server.listen("127.0.0.1:6767").await.unwrap();
}