actix_prost_build/
config.rs1use serde::Deserialize;
2
3#[derive(Debug, Clone, Deserialize)]
4#[serde(rename_all = "snake_case")]
5pub enum Pattern {
6 Get(String),
7 Put(String),
8 Post(String),
9 Delete(String),
10 Patch(String),
11 }
13
14impl Pattern {
15 pub fn path(&self) -> &String {
16 match self {
17 Self::Get(p) => p,
18 Self::Put(p) => p,
19 Self::Post(p) => p,
20 Self::Delete(p) => p,
21 Self::Patch(p) => p,
22 }
23 }
24
25 pub fn method(&self) -> &str {
26 match self {
27 Self::Get(_) => "get",
28 Self::Put(_) => "put",
29 Self::Post(_) => "post",
30 Self::Delete(_) => "delete",
31 Self::Patch(_) => "patch",
32 }
33 }
34}
35
36#[derive(Debug, Clone, Deserialize)]
37pub struct HttpRule {
38 pub selector: String,
39 #[serde(flatten)]
40 pub pattern: Pattern,
41 pub body: Option<String>,
42 pub response_body: Option<String>,
43}
44
45#[derive(Debug, Clone, Deserialize)]
46pub struct Http {
47 pub rules: Vec<HttpRule>,
48}
49
50#[derive(Debug, Clone, Deserialize)]
51pub struct Config {
52 pub http: Http,
53}