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
use super::{Attributes, Loc, RpChannel, RpPathSpec};
use linked_hash_map::LinkedHashMap;
#[derive(Debug, Clone, Serialize)]
pub enum RpHttpMethod {
GET,
POST,
PUT,
UPDATE,
DELETE,
PATCH,
HEAD,
}
#[derive(Debug, Clone, Serialize, Default)]
pub struct RpEndpointHttp {
pub path: Option<RpPathSpec>,
pub body: Option<String>,
pub method: Option<RpHttpMethod>,
}
#[derive(Debug, Clone, Serialize)]
pub struct RpEndpoint {
pub id: Loc<String>,
pub name: String,
pub comment: Vec<String>,
pub attributes: Attributes,
pub arguments: LinkedHashMap<String, (Loc<String>, Loc<RpChannel>)>,
pub response: Option<Loc<RpChannel>>,
pub http: RpEndpointHttp,
}
impl RpEndpoint {
pub fn id_parts<F>(&self, filter: F) -> Vec<String>
where
F: Fn(&str) -> String,
{
vec![filter(self.id.as_str())]
}
pub fn name(&self) -> &str {
self.name.as_str()
}
}