pub struct Method(_);
Expand description
The Request Method (VERB)
This type also contains constants for a number of common HTTP methods such as GET, POST, etc.
Currently includes 8 variants representing the 8 methods defined in RFC 7230, plus PATCH, and an Extension variant for all extensions.
Examples
use http::Method;
assert_eq!(Method::GET, Method::from_bytes(b"GET").unwrap());
assert!(Method::GET.is_idempotent());
assert_eq!(Method::POST.as_str(), "POST");
Implementations
sourceimpl Method
impl Method
sourcepub fn from_bytes(src: &[u8]) -> Result<Method, InvalidMethod>
pub fn from_bytes(src: &[u8]) -> Result<Method, InvalidMethod>
Converts a slice of bytes to an HTTP method.
sourcepub fn is_safe(&self) -> bool
pub fn is_safe(&self) -> bool
Whether a method is considered “safe”, meaning the request is essentially read-only.
See the spec for more words.
sourcepub fn is_idempotent(&self) -> bool
pub fn is_idempotent(&self) -> bool
Whether a method is considered “idempotent”, meaning the request has the same result if executed multiple times.
See the spec for more words.
Trait Implementations
sourceimpl FromRequest for Method
impl FromRequest for Method
Extract the request’s method.
Examples
use actix_web::{http::Method, web, App, Responder};
async fn handler(method: Method) -> impl Responder {
format!("Request method: {}", method)
}
let app = App::new().default_service(web::to(handler));
type Error = Infallible
type Error = Infallible
The associated error which can be returned.
sourcefn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future
fn from_request(req: &HttpRequest, _: &mut Payload) -> Self::Future
Create a Self from request parts asynchronously.
sourcefn extract(req: &HttpRequest) -> Self::Future
fn extract(req: &HttpRequest) -> Self::Future
Create a Self from request head asynchronously. Read more
impl Eq for Method
impl StructuralEq for Method
impl StructuralPartialEq for Method
Auto Trait Implementations
impl RefUnwindSafe for Method
impl Send for Method
impl Sync for Method
impl Unpin for Method
impl UnwindSafe for Method
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<T> CallHasher for T where
T: Hash + ?Sized,
impl<T> CallHasher for T where
T: Hash + ?Sized,
sourceimpl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
impl<Q, K> Equivalent<K> for Q where
Q: Eq + ?Sized,
K: Borrow<Q> + ?Sized,
sourcefn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to key
and return true
if they are equal.
sourceimpl<T> Instrument for T
impl<T> Instrument for T
sourcefn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
sourcefn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
sourceimpl<T> WithSubscriber for T
impl<T> WithSubscriber for T
sourcefn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self> where
S: Into<Dispatch>,
Attaches the provided Subscriber
to this type, returning a
WithDispatch
wrapper. Read more
sourcefn with_current_subscriber(self) -> WithDispatch<Self>
fn with_current_subscriber(self) -> WithDispatch<Self>
Attaches the current default Subscriber
to this type, returning a
WithDispatch
wrapper. Read more