mirror of https://github.com/fafhrd91/actix-web
add `Method` example
This commit is contained in:
parent
73e852c7a9
commit
39446fe262
|
@ -254,6 +254,22 @@ impl FromRequest for Version {
|
|||
}
|
||||
}
|
||||
|
||||
/// Extract the request's method.
|
||||
///
|
||||
/// ## Example
|
||||
///
|
||||
/// ```
|
||||
/// use actix_web::{web, App, HttpRequest, http::Method};
|
||||
///
|
||||
/// async fn index(method: Method) -> &'static str {
|
||||
/// assert_eq!(method, Method::GET);
|
||||
/// "Welcome!"
|
||||
/// }
|
||||
///
|
||||
/// fn main() {
|
||||
/// let app = App::new().route("/", web::get().to(index));
|
||||
/// }
|
||||
/// ```
|
||||
impl FromRequest for Method {
|
||||
type Error = Infallible;
|
||||
type Future = Ready<Result<Method, Infallible>>;
|
||||
|
|
Loading…
Reference in New Issue