Skip to main content

neco_server_core/
method.rs

1/// HTTP method.
2#[derive(Clone, Debug, PartialEq, Eq)]
3pub enum Method {
4    /// GET
5    Get,
6    /// POST
7    Post,
8    /// PUT
9    Put,
10    /// DELETE
11    Delete,
12    /// PATCH
13    Patch,
14    /// HEAD
15    Head,
16    /// OPTIONS
17    Options,
18    /// Any other method token.
19    Other(String),
20}
21
22impl Method {
23    /// Returns the canonical method token.
24    pub fn as_str(&self) -> &str {
25        match self {
26            Self::Get => "GET",
27            Self::Post => "POST",
28            Self::Put => "PUT",
29            Self::Delete => "DELETE",
30            Self::Patch => "PATCH",
31            Self::Head => "HEAD",
32            Self::Options => "OPTIONS",
33            Self::Other(value) => value.as_str(),
34        }
35    }
36}