Parse a method string into a typed variant (case-insensitive).
(s: &str)
| 57 | |
| 58 | /// Parse a method string into a typed variant (case-insensitive). |
| 59 | fn from_str(s: &str) -> Result<Self, Self::Err> { |
| 60 | Ok(match s.to_uppercase().as_str() { |
| 61 | "OPTIONS" => Self::Options, |
| 62 | "GET" => Self::Get, |
| 63 | "HEAD" => Self::Head, |
| 64 | "POST" => Self::Post, |
| 65 | "PUT" => Self::Put, |
| 66 | "DELETE" => Self::Delete, |
| 67 | "TRACE" => Self::Trace, |
| 68 | "CONNECT" => Self::Connect, |
| 69 | "PATCH" => Self::Patch, |
| 70 | _ => Self::Other(s.to_string()), |
| 71 | }) |
| 72 | } |
| 73 | } |
| 74 | |
| 75 | impl Serialize for HttpMethod { |