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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
//! A declarative routing DSL that makes trust boundaries obvious.
pub use ;
pub use *;
pub use MethodNotAllowed;
use Arc;
use ;
use crateMiddleware;
/// Returns a partially applied function that attaches `middleware` to a path.
///
/// This is intended to be used with [`Route::map`], allowing middleware to be
/// composed into a route without having to write a closure.
///
/// # Example
///
/// ```
/// # via::Router::new(|home| {
/// # let mut path = home.prefix();
/// // Define the /api namespace.
/// let mut api = path.push("/api");
///
/// // Start defining descendants of "/api".
/// let mut path = api.prefix();
///
/// // Define the /api/auth resource.
/// path.route("/auth", via::post(login).delete(logout))
/// // Continue defining the /api/auth resource from /api/auth/me.
/// .push("/me")
/// // Requests to /api/auth/me require an authenticated user.
/// .map(via::router::apply(authenticate))
/// // GET /api/auth/me responds with the active user as JSON.
/// .assign(via::get(me));
/// # });
/// #
/// # async fn authenticate(_: via::Request, _: via::Next) -> via::Result { unimplemented!() }
/// # async fn login(_: via::Request, _: via::Next) -> via::Result { unimplemented!() }
/// # async fn logout(_: via::Request, _: via::Next) -> via::Result { unimplemented!() }
/// # async fn me(_: via::Request, _: via::Next) -> via::Result { unimplemented!() }
/// ```