1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#[derive(Clone, Debug)]
pub enum Method {
    Post,
    Get,
}

impl std::str::FromStr for Method {
    type Err = anyhow::Error;

    fn from_str(s: &str) -> anyhow::Result<Self> {
        match s.to_string().to_lowercase().as_str() {
            "post" => Ok(Self::Post),
            "get" => Ok(Self::Get),
            _ => anyhow::bail!("unsupported method"),
        }
    }
}