pub enum Method {
GET,
POST,
PUT,
DELETE,
OPTIONS,
HEAD,
PATCH,
TRACE,
ANY,
}
Expand description
HTTP Methods.
Also contains a special method (ANY) for routes that run on all methods, which will never be the method of a request. From https://developer.mozilla.org/en-US/docs/Web/HTTP/Methods.
Variants§
GET
HTTP GET Method. MDN
Used for retrieving data
POST
HTTP POST Method. MDN
Used for submitting data
PUT
HTTP PUT Method. MDN
Used for updating data
DELETE
HTTP DELETE Method. MDN
Used for deleting data
OPTIONS
HTTP OPTIONS Method. MDN
Used for requesting information about the server
HEAD
HTTP HEAD Method. MDN
For getting the response from a GET request without the body
PATCH
HTTP PATCH Method. MDN
Used for applying a partial update to a resource
TRACE
HTTP TRACE Method. MDN
Used for tracing the route of a request
ANY
For routes that run on all methods
Will not be use in a request
Trait Implementations§
source§impl FromStr for Method
impl FromStr for Method
source§fn from_str(s: &str) -> Result<Self, Self::Err>
fn from_str(s: &str) -> Result<Self, Self::Err>
Convert a string to a method. If the string is not a valid method or is ANY, an error will be returned.
Examples
assert!(Method::from_str("GET").unwrap() == Method::GET);
assert!(Method::from_str("POST").unwrap() == Method::POST);
assert!(Method::from_str("PUT").unwrap() == Method::PUT);
assert!(Method::from_str("DELETE").unwrap() == Method::DELETE);
assert!(Method::from_str("OPTIONS").unwrap() == Method::OPTIONS);
assert!(Method::from_str("HEAD").unwrap() == Method::HEAD);
assert!(Method::from_str("PATCH").unwrap() == Method::PATCH);
assert!(Method::from_str("TRACE").unwrap() == Method::TRACE);
assert!(Method::from_str("ANY") == Err(()));
assert!(Method::from_str("foo") == Err(()));