rocal_core/enums/
request_method.rs1use core::fmt;
2
3#[derive(Debug)]
4pub enum RequestMethod {
5 Get,
6 Post,
7 Put,
8 Patch,
9 Delete,
10}
11
12impl RequestMethod {
13 pub fn from(method: &str) -> Self {
14 match method.to_uppercase().as_str() {
15 "GET" => RequestMethod::Get,
16 "POST" => RequestMethod::Post,
17 "PUT" => RequestMethod::Put,
18 "PATCH" => RequestMethod::Patch,
19 "DELETE" => RequestMethod::Delete,
20 _ => RequestMethod::Post,
21 }
22 }
23}
24
25impl fmt::Display for RequestMethod {
26 fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
27 match self {
28 RequestMethod::Get => write!(f, "GET"),
29 RequestMethod::Post => write!(f, "POST"),
30 RequestMethod::Put => write!(f, "PUT"),
31 RequestMethod::Patch => write!(f, "PATCH"),
32 RequestMethod::Delete => write!(f, "DELETE"),
33 }
34 }
35}