pub struct Extractor<T>(/* private fields */);
Expand description
An HTTP request extractor.
Trait Implementations§
Source§impl From<Extractor<HttpRequest>> for HttpRequest
impl From<Extractor<HttpRequest>> for HttpRequest
Source§fn from(extractor: Extractor<HttpRequest>) -> Self
fn from(extractor: Extractor<HttpRequest>) -> Self
Converts to this type from the input type.
Source§impl From<HttpRequest> for Extractor<HttpRequest>
impl From<HttpRequest> for Extractor<HttpRequest>
Source§fn from(request: HttpRequest) -> Self
fn from(request: HttpRequest) -> Self
Converts to this type from the input type.
Source§impl<Err: ErrorRenderer> From<WebRequest<Err>> for Extractor<HttpRequest>
impl<Err: ErrorRenderer> From<WebRequest<Err>> for Extractor<HttpRequest>
Source§fn from(request: WebRequest<Err>) -> Self
fn from(request: WebRequest<Err>) -> Self
Converts to this type from the input type.
Source§impl FromRequest<DefaultError> for Extractor<HttpRequest>
impl FromRequest<DefaultError> for Extractor<HttpRequest>
Source§type Error = Infallible
type Error = Infallible
The associated error which can be returned.
Source§async fn from_request(
req: &HttpRequest,
payload: &mut Payload,
) -> Result<Self, Self::Error>
async fn from_request( req: &HttpRequest, payload: &mut Payload, ) -> Result<Self, Self::Error>
Convert request to a Self
Source§impl RequestContext for Extractor<HttpRequest>
impl RequestContext for Extractor<HttpRequest>
Source§fn request_method(&self) -> &Self::Method
fn request_method(&self) -> &Self::Method
Returns the request method.
Source§fn original_uri(&self) -> &Self::Uri
fn original_uri(&self) -> &Self::Uri
Returns the original request URI regardless of nesting.
Source§fn matched_route(&self) -> Cow<'_, str>
fn matched_route(&self) -> Cow<'_, str>
Returns the route that matches the request.
Source§fn request_path(&self) -> &str
fn request_path(&self) -> &str
Returns the request path regardless of nesting.
Source§fn get_query_string(&self) -> Option<&str>
fn get_query_string(&self) -> Option<&str>
Gets the query string of the request.
Source§fn get_header(&self, name: &str) -> Option<&str>
fn get_header(&self, name: &str) -> Option<&str>
Gets an HTTP header value with the given name.
Source§fn get_context(&self) -> Option<Context>
fn get_context(&self) -> Option<Context>
Gets the request context.
Source§fn get_data<T: Clone + Send + Sync + 'static>(&self) -> Option<T>
fn get_data<T: Clone + Send + Sync + 'static>(&self) -> Option<T>
Gets the request scoped data.
Source§fn set_data<T: Clone + Send + Sync + 'static>(&mut self, value: T) -> Option<T>
fn set_data<T: Clone + Send + Sync + 'static>(&mut self, value: T) -> Option<T>
Sets the request scoped data and returns the old value
if an item of this type was already stored.
Source§async fn read_body_bytes(&mut self) -> Result<Vec<u8>, Error>
async fn read_body_bytes(&mut self) -> Result<Vec<u8>, Error>
Reads the entire request body into a byte buffer.
Source§fn path_segments(&self) -> Vec<&str>
fn path_segments(&self) -> Vec<&str>
Returns the request path segments.
Source§fn new_context(&self) -> Context
fn new_context(&self) -> Context
Creates a new request context.
Source§fn get_trace_context(&self) -> Option<TraceContext>
fn get_trace_context(&self) -> Option<TraceContext>
Returns the trace context by parsing the
traceparent
and tracestate
header values.Source§fn new_trace_context(&self) -> TraceContext
fn new_trace_context(&self) -> TraceContext
Creates a new
TraceContext
.Source§fn start_time(&self) -> Instant
fn start_time(&self) -> Instant
Returns the start time.
Source§fn request_id(&self) -> Uuid
fn request_id(&self) -> Uuid
Returns the request ID.
Source§fn session_id(&self) -> Option<String>
fn session_id(&self) -> Option<String>
Returns the session ID.
Source§fn data_type(&self) -> Option<&str>
fn data_type(&self) -> Option<&str>
Gets the data type by parsing the
content-type
header. Read moreSource§fn decode_param(&self, name: &str) -> Result<Cow<'_, str>, Rejection>
fn decode_param(&self, name: &str) -> Result<Cow<'_, str>, Rejection>
Decodes the UTF-8 percent-encoded route parameter by name.
Source§fn parse_param<T>(&self, name: &str) -> Result<T, Rejection>
fn parse_param<T>(&self, name: &str) -> Result<T, Rejection>
Parses the route parameter by name as an instance of type
T
.
The name should not include :
, *
, {
or }
.Source§fn get_query(&self, name: &str) -> Option<&str>
fn get_query(&self, name: &str) -> Option<&str>
Gets the query value of the URI by name. Read more
Source§fn decode_query(&self, name: &str) -> Result<Cow<'_, str>, Rejection>
fn decode_query(&self, name: &str) -> Result<Cow<'_, str>, Rejection>
Decodes the UTF-8 percent-encoded query value of the URI by name.
Source§fn parse_query<T>(&self) -> Result<T, Rejection>where
T: Default + DeserializeOwned,
fn parse_query<T>(&self) -> Result<T, Rejection>where
T: Default + DeserializeOwned,
Parses the query as an instance of type
T
.
Returns a default value of T
when the query is empty.
If the query has a timestamp
parameter, it will be used to prevent replay attacks.Source§async fn parse_body<T>(&mut self) -> Result<T, Rejection>where
T: DeserializeOwned,
async fn parse_body<T>(&mut self) -> Result<T, Rejection>where
T: DeserializeOwned,
Parses the request body as an instance of type
T
. Read moreSource§async fn parse_multipart(&mut self) -> Result<Multipart<'_>, Rejection>
async fn parse_multipart(&mut self) -> Result<Multipart<'_>, Rejection>
Parses the request body as a multipart, which is commonly used with file uploads.
Source§async fn parse_file(&mut self) -> Result<NamedFile, Rejection>
async fn parse_file(&mut self) -> Result<NamedFile, Rejection>
Parses the request body as a file.
Source§async fn parse_files(&mut self) -> Result<Vec<NamedFile>, Rejection>
async fn parse_files(&mut self) -> Result<Vec<NamedFile>, Rejection>
Parses the request body as a list of files.
Source§async fn parse_form_data<T>(&mut self) -> Result<(T, Vec<NamedFile>), Rejection>where
T: DeserializeOwned,
async fn parse_form_data<T>(&mut self) -> Result<(T, Vec<NamedFile>), Rejection>where
T: DeserializeOwned,
Parses the
multipart/form-data
as an instance of type T
and a list of files.Source§fn query_validation<S>(
&self,
query: &mut Query,
) -> Result<Response<S>, Rejection>where
Self: Sized,
S: ResponseCode,
fn query_validation<S>(
&self,
query: &mut Query,
) -> Result<Response<S>, Rejection>where
Self: Sized,
S: ResponseCode,
Returns a
Response
or Rejection
from a model query validation.
The data is extracted from parse_query()
.Source§async fn model_validation<M, S>(
&mut self,
model: &mut M,
) -> Result<Response<S>, Rejection>
async fn model_validation<M, S>( &mut self, model: &mut M, ) -> Result<Response<S>, Rejection>
Source§async fn fetch(
&self,
url: &str,
options: Option<&Map<String, Value>>,
) -> Result<Response, Error>
async fn fetch( &self, url: &str, options: Option<&Map<String, Value>>, ) -> Result<Response, Error>
Makes an HTTP request to the provided URL.
Source§async fn fetch_json<T>(
&self,
url: &str,
options: Option<&Map<String, Value>>,
) -> Result<T, Error>where
T: DeserializeOwned,
async fn fetch_json<T>(
&self,
url: &str,
options: Option<&Map<String, Value>>,
) -> Result<T, Error>where
T: DeserializeOwned,
Makes an HTTP request to the provided URL and
deserializes the response body via JSON.
Source§fn subscription(&self) -> Subscription
fn subscription(&self) -> Subscription
Constructs a new subscription instance.
Source§fn cloud_event(&self, event_type: Cow<'static, str>, data: Value) -> CloudEvent
fn cloud_event(&self, event_type: Cow<'static, str>, data: Value) -> CloudEvent
Constructs a new cloud event instance.
Source§impl<Err: ErrorRenderer> TryFrom<Extractor<HttpRequest>> for WebRequest<Err>
impl<Err: ErrorRenderer> TryFrom<Extractor<HttpRequest>> for WebRequest<Err>
Auto Trait Implementations§
impl<T> Freeze for Extractor<T>where
T: Freeze,
impl<T> !RefUnwindSafe for Extractor<T>
impl<T> !Send for Extractor<T>
impl<T> !Sync for Extractor<T>
impl<T> Unpin for Extractor<T>where
T: Unpin,
impl<T> !UnwindSafe for Extractor<T>
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more