gateway_internal/
http_rule.rs1#[derive(Debug, Clone, PartialEq)]
4pub struct HttpRule {
5 pub selector: String,
7
8 pub pattern: Pattern,
10
11 pub body: String,
13
14 pub response_body: String,
16
17 pub additional_bindings: Vec<HttpRule>,
19}
20
21#[cfg(test)]
22mod tests {
23 use super::*;
24
25 #[test]
26 fn test_http_rule_creation() {
27 let rule = HttpRule {
28 selector: "example.Service.Method".to_string(),
29 pattern: Pattern::Get("/v1/example".to_string()),
30 body: "*".to_string(),
31 response_body: "".to_string(),
32 additional_bindings: vec![],
33 };
34
35 assert_eq!(rule.selector, "example.Service.Method");
36 match rule.pattern {
37 Pattern::Get(path) => assert_eq!(path, "/v1/example"),
38 _ => panic!("Expected GET pattern"),
39 }
40 }
41}
42
43#[derive(Debug, Clone, PartialEq)]
44pub enum Pattern {
45 Get(String),
46 Put(String),
47 Post(String),
48 Delete(String),
49 Patch(String),
50 Custom { kind: String, path: String },
51}