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
use super::{HandleFunc, Handler, Param};
#[allow(non_snake_case)]
pub struct HandlerGroup {
pub(crate) max_param_count: u8,
pub(crate) GET: Option<HandleFunc>,
pub(crate) POST: Option<HandleFunc>,
pub(crate) PATCH: Option<HandleFunc>,
pub(crate) DELETE: Option<HandleFunc>,
} impl HandlerGroup {
#[allow(non_snake_case)]
pub fn GET<H: Handler<P>, P: Param>(mut self, handler: H) -> Self {
let (handler, param_count) = handler.into_handlefunc();
self.max_param_count = self.max_param_count.max(param_count);
HandlerGroup {
GET: Some(handler),
..self
}
}
#[allow(non_snake_case)]
pub fn POST<H: Handler<P>, P: Param>(mut self, handler: H) -> Self {
let (handler, param_count) = handler.into_handlefunc();
self.max_param_count = self.max_param_count.max(param_count);
HandlerGroup {
POST: Some(handler),
..self
}
}
#[allow(non_snake_case)]
pub fn PATCH<H: Handler<P>, P: Param>(mut self, handler: H) -> Self {
let (handler, param_count) = handler.into_handlefunc();
self.max_param_count = self.max_param_count.max(param_count);
HandlerGroup {
PATCH: Some(handler),
..self
}
}
#[allow(non_snake_case)]
pub fn DELETE<H: Handler<P>, P: Param>(mut self, handler: H) -> Self {
let (handler, param_count) = handler.into_handlefunc();
self.max_param_count = self.max_param_count.max(param_count);
HandlerGroup {
DELETE: Some(handler),
..self
}
}
}
#[allow(non_snake_case, unused)]
pub fn GET<H: Handler<P>, P: Param>(handler: H) -> HandlerGroup {
let (handler, param_count) = handler.into_handlefunc();
HandlerGroup {
max_param_count: param_count,
GET: Some(handler),
POST: None,
PATCH: None,
DELETE: None,
}
}
#[allow(non_snake_case, unused)]
pub fn POST<H: Handler<P>, P: Param>(handler: H) -> HandlerGroup {
let (handler, param_count) = handler.into_handlefunc();
HandlerGroup {
max_param_count: param_count,
GET: None,
POST: Some(handler),
PATCH: None,
DELETE: None,
}
}
#[allow(non_snake_case, unused)]
pub fn PATCH<H: Handler<P>, P: Param>(handler: H) -> HandlerGroup {
let (handler, param_count) = handler.into_handlefunc();
HandlerGroup {
max_param_count: param_count,
GET: None,
POST: None,
PATCH: Some(handler),
DELETE: None,
}
}
#[allow(non_snake_case, unused)]
pub fn DELETE<H: Handler<P>, P: Param>(handler: H) -> HandlerGroup {
let (handler, param_count) = handler.into_handlefunc();
HandlerGroup {
max_param_count: param_count,
GET: None,
POST: None,
PATCH: None,
DELETE: Some(handler),
}
}