The set of HTTP methods this endpoint allows. Empty means all (L4-only).
(&self)
| 204 | |
| 205 | /// The set of HTTP methods this endpoint allows. Empty means all (L4-only). |
| 206 | pub fn allowed_methods(&self) -> HashSet<String> { |
| 207 | if self.protocol.is_empty() { |
| 208 | return HashSet::new(); // L4-only: all traffic passes |
| 209 | } |
| 210 | match self.access.as_str() { |
| 211 | "read-only" => ["GET", "HEAD", "OPTIONS"] |
| 212 | .iter() |
| 213 | .map(|s| (*s).to_owned()) |
| 214 | .collect(), |
| 215 | "read-write" => ["GET", "HEAD", "OPTIONS", "POST", "PUT", "PATCH"] |
| 216 | .iter() |
| 217 | .map(|s| (*s).to_owned()) |
| 218 | .collect(), |
| 219 | "full" => ALL_METHODS.iter().map(|s| (*s).to_owned()).collect(), |
| 220 | _ => { |
| 221 | if !self.rules.is_empty() { |
| 222 | let mut methods = HashSet::new(); |
| 223 | for r in &self.rules { |
| 224 | let m = r.method.to_uppercase(); |
| 225 | if m == "*" { |
| 226 | return ALL_METHODS.iter().map(|s| (*s).to_owned()).collect(); |
| 227 | } |
| 228 | methods.insert(m); |
| 229 | } |
| 230 | return methods; |
| 231 | } |
| 232 | HashSet::new() |
| 233 | } |
| 234 | } |
| 235 | } |
| 236 | } |
| 237 | |
| 238 | /// A binary path entry in a network policy rule. |
no test coverage detected