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
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
//! # tackt
//!
//! > HTTP router for [tower][tower] service.
//!
//! ## usage overview
//!
//! ```rust
//! use tackt::route;
//! use tackt::routes;
//!
//! #[route(GET, PUT: "entity" / id / "resource" / path*)]
//! async fn resource(
//! req: http::Request<hyper::Body>,
//! id: i32,
//! path: String,
//! ) -> Result<http::Response<hyper::Body>, Box<dyn std::error::Error>> {
//! let content = format!("resource: {id} {path}");
//! let body = hyper::Body::from(content);
//! let response = http::Response::new(body);
//! Ok(response)
//! }
//!
//! let router = routes![resource];
//! // use the `router` in `hyper::service::make_service_fn`.
//! ```
//!
//! **NOTE**: `#[route]` attribute changes the function signature.
//!
//! ## route spec examples
//!
//! 1. Empty
//!
//! This spec will match exactly `"/"` on any methods.
//!
//! ```rust,ignore
//! #[route]
//! ```
//!
//! 1. Only methods
//!
//! This spec will match exactly `"/"` only on `GET` or `PUT` request.
//!
//! ```rust,ignore
//! #[route(GET, PUT)]
//! ```
//!
//! 1. Only segments
//!
//! This spec will match exactly `"/path/to/somewhere"` on any methods.
//!
//! ```rust,ignore
//! #[route("path" / "to" / "somewhere")]
//! ```
//!
//! 1. Methods and segments
//!
//! This spec will match exactly `"/path/to/somewhere"` only on `GET` request.
//!
//! ```rust,ignore
//! #[route(GET: "path" / "to" / "somewhere")]
//! ```
//!
//! ## route syntax:
//!
//! ```text
//! spec: methods ':' segments
//! / methods
//! / segments
//! / empty
//!
//! methods: identifier [',' identifier]*
//!
//! segments: segment ['/' segment]* ['/' rest]
//!
//! segment: literal-str / identifier
//!
//! rest: identifier '*'
//!
//! empty:
//! ```
//!
//! [tower]: https://crates.io/crates/tower
pub use Error;
pub use Param;
pub use Route;
pub use Router;
pub use Void;
pub use MethodReq;
pub use PathReq;
pub use RemovePrefix;
pub use Func;
pub use Mount;
pub use Or;
pub use Method;
pub use Service;
/// The attribute to describe route's spec.
///
/// See [the top-level documentation][lib].
///
/// [lib]: index.html
pub use route;
/// Derive [`Param`][crate::param::Param] for struct.
///
/// See [`Param` doc][crate::param::Param].
pub use Param;