rama_http::matcher

Struct HttpMatcher

Source
pub struct HttpMatcher<State, Body> { /* private fields */ }
Expand description

A matcher that is used to match an http Request

Implementations§

Source§

impl<State, Body> HttpMatcher<State, Body>

Source

pub fn method(method: MethodMatcher) -> Self

Create a new matcher that matches one or more HTTP methods.

See MethodMatcher for more information.

Source

pub fn and_method(self, method: MethodMatcher) -> Self

Create a matcher that also matches one or more HTTP methods on top of the existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn or_method(self, method: MethodMatcher) -> Self

Create a matcher that can also match one or more HTTP methods as an alternative to the existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn method_delete() -> Self

Create a new matcher that matches MethodMatcher::DELETE requests.

See MethodMatcher for more information.

Source

pub fn and_method_delete(self) -> Self

Add a new matcher that also matches MethodMatcher::DELETE on top of the existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn or_method_delete(self) -> Self

Add a new matcher that can also match MethodMatcher::DELETE as an alternative tothe existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn method_get() -> Self

Create a new matcher that matches MethodMatcher::GET requests.

See MethodMatcher for more information.

Source

pub fn and_method_get(self) -> Self

Add a new matcher that also matches MethodMatcher::GET on top of the existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn or_method_get(self) -> Self

Add a new matcher that can also match MethodMatcher::GET as an alternative tothe existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn method_head() -> Self

Create a new matcher that matches MethodMatcher::HEAD requests.

See MethodMatcher for more information.

Source

pub fn and_method_head(self) -> Self

Add a new matcher that also matches MethodMatcher::HEAD on top of the existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn or_method_head(self) -> Self

Add a new matcher that can also match MethodMatcher::HEAD as an alternative tothe existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn method_options() -> Self

Create a new matcher that matches MethodMatcher::OPTIONS requests.

See MethodMatcher for more information.

Source

pub fn and_method_options(self) -> Self

Add a new matcher that also matches MethodMatcher::OPTIONS on top of the existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn or_method_options(self) -> Self

Add a new matcher that can also match MethodMatcher::OPTIONS as an alternative tothe existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn method_patch() -> Self

Create a new matcher that matches MethodMatcher::PATCH requests.

See MethodMatcher for more information.

Source

pub fn and_method_patch(self) -> Self

Add a new matcher that also matches MethodMatcher::PATCH on top of the existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn or_method_patch(self) -> Self

Add a new matcher that can also match MethodMatcher::PATCH as an alternative tothe existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn method_post() -> Self

Create a new matcher that matches MethodMatcher::POST requests.

See MethodMatcher for more information.

Source

pub fn and_method_post(self) -> Self

Add a new matcher that also matches MethodMatcher::POST on top of the existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn or_method_post(self) -> Self

Add a new matcher that can also match MethodMatcher::POST as an alternative tothe existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn method_put() -> Self

Create a new matcher that matches MethodMatcher::PUT requests.

See MethodMatcher for more information.

Source

pub fn and_method_put(self) -> Self

Add a new matcher that also matches MethodMatcher::PUT on top of the existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn or_method_put(self) -> Self

Add a new matcher that can also match MethodMatcher::PUT as an alternative tothe existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn method_trace() -> Self

Create a new matcher that matches MethodMatcher::TRACE requests.

See MethodMatcher for more information.

Source

pub fn and_method_trace(self) -> Self

Add a new matcher that also matches MethodMatcher::TRACE on top of the existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn or_method_trace(self) -> Self

Add a new matcher that can also match MethodMatcher::TRACE as an alternative tothe existing HttpMatcher matchers.

See MethodMatcher for more information.

Source

pub fn domain(domain: Domain) -> Self

Create a DomainMatcher matcher, matching on the exact given Domain.

Source

pub fn subdomain(domain: Domain) -> Self

Create a DomainMatcher matcher, matching on the exact given Domain or a subdomain of it.

Source

pub fn and_domain(self, domain: Domain) -> Self

Create a DomainMatcher matcher to also match on top of the existing set of HttpMatcher matchers.

See Self::domain for more information.

Source

pub fn and_subdomain(self, domain: Domain) -> Self

Create a sub DomainMatcher matcher to also match on top of the existing set of HttpMatcher matchers.

See Self::subdomain for more information.

Source

pub fn or_domain(self, domain: Domain) -> Self

Create a DomainMatcher matcher to match as an alternative to the existing set of HttpMatcher matchers.

See Self::domain for more information.

Source

pub fn or_subdomain(self, domain: Domain) -> Self

Create a sub DomainMatcher matcher to match as an alternative to the existing set of HttpMatcher matchers.

See Self::subdomain for more information.

Source

pub fn version(version: VersionMatcher) -> Self

Create a VersionMatcher matcher.

Source

pub fn and_version(self, version: VersionMatcher) -> Self

Add a VersionMatcher matcher to matcher on top of the existing set of HttpMatcher matchers.

See VersionMatcher for more information.

Source

pub fn or_version(self, version: VersionMatcher) -> Self

Create a VersionMatcher matcher to match as an alternative to the existing set of HttpMatcher matchers.

See VersionMatcher for more information.

Source

pub fn uri(re: impl AsRef<str>) -> Self

Create a UriMatcher matcher.

Source

pub fn and_uri(self, re: impl AsRef<str>) -> Self

Create a UriMatcher matcher to match on top of the existing set of HttpMatcher matchers.

See UriMatcher for more information.

Source

pub fn or_uri(self, re: impl AsRef<str>) -> Self

Create a UriMatcher matcher to match as an alternative to the existing set of HttpMatcher matchers.

See UriMatcher for more information.

Source

pub fn path(path: impl AsRef<str>) -> Self

Create a PathMatcher matcher.

Source

pub fn and_path(self, path: impl AsRef<str>) -> Self

Add a PathMatcher to match on top of the existing set of HttpMatcher matchers.

See PathMatcher for more information.

Source

pub fn or_path(self, path: impl AsRef<str>) -> Self

Create a PathMatcher matcher to match as an alternative to the existing set of HttpMatcher matchers.

See PathMatcher for more information.

Source

pub fn header(name: HeaderName, value: HeaderValue) -> Self

Create a HeaderMatcher matcher.

Source

pub fn and_header(self, name: HeaderName, value: HeaderValue) -> Self

Add a HeaderMatcher to match on top of the existing set of HttpMatcher matchers.

See HeaderMatcher for more information.

Source

pub fn or_header(self, name: HeaderName, value: HeaderValue) -> Self

Create a HeaderMatcher matcher to match as an alternative to the existing set of HttpMatcher matchers.

See HeaderMatcher for more information.

Source

pub fn header_exists(name: HeaderName) -> Self

Create a HeaderMatcher matcher when the given header exists to match on the existence of a header.

Source

pub fn and_header_exists(self, name: HeaderName) -> Self

Add a HeaderMatcher to match when the given header exists on top of the existing set of HttpMatcher matchers.

See HeaderMatcher for more information.

Source

pub fn or_header_exists(self, name: HeaderName) -> Self

Create a HeaderMatcher matcher to match when the given header exists as an alternative to the existing set of HttpMatcher matchers.

See HeaderMatcher for more information.

Source

pub fn header_contains(name: HeaderName, value: HeaderValue) -> Self

Create a HeaderMatcher matcher to match on it containing the given value.

Source

pub fn and_header_contains(self, name: HeaderName, value: HeaderValue) -> Self

Add a HeaderMatcher to match when it contains the given value on top of the existing set of HttpMatcher matchers.

See HeaderMatcher for more information.

Source

pub fn or_header_contains(self, name: HeaderName, value: HeaderValue) -> Self

Create a HeaderMatcher matcher to match if it contains the given value as an alternative to the existing set of HttpMatcher matchers.

See HeaderMatcher for more information.

Source

pub fn socket(socket: SocketMatcher<State, Request<Body>>) -> Self

Create a SocketMatcher matcher.

Source

pub fn and_socket(self, socket: SocketMatcher<State, Request<Body>>) -> Self

Add a SocketMatcher matcher to match on top of the existing set of HttpMatcher matchers.

See SocketMatcher for more information.

Source

pub fn or_socket(self, socket: SocketMatcher<State, Request<Body>>) -> Self

Create a SocketMatcher matcher to match as an alternative to the existing set of HttpMatcher matchers.

See SocketMatcher for more information.

Source

pub fn get(path: impl AsRef<str>) -> Self

Create a PathMatcher matcher to match for a GET request.

Source

pub fn custom<M>(matcher: M) -> Self
where M: Matcher<State, Request<Body>>,

Create a matcher that matches according to a custom predicate.

See rama_core::matcher::Matcher for more information.

Source

pub fn and_custom<M>(self, matcher: M) -> Self
where M: Matcher<State, Request<Body>>,

Add a custom matcher to match on top of the existing set of HttpMatcher matchers.

See rama_core::matcher::Matcher for more information.

Source

pub fn or_custom<M>(self, matcher: M) -> Self
where M: Matcher<State, Request<Body>>,

Create a custom matcher to match as an alternative to the existing set of HttpMatcher matchers.

See rama_core::matcher::Matcher for more information.

Source

pub fn post(path: impl AsRef<str>) -> Self

Create a PathMatcher matcher to match for a POST request.

Source

pub fn put(path: impl AsRef<str>) -> Self

Create a PathMatcher matcher to match for a PUT request.

Source

pub fn delete(path: impl AsRef<str>) -> Self

Create a PathMatcher matcher to match for a DELETE request.

Source

pub fn patch(path: impl AsRef<str>) -> Self

Create a PathMatcher matcher to match for a PATCH request.

Source

pub fn head(path: impl AsRef<str>) -> Self

Create a PathMatcher matcher to match for a HEAD request.

Source

pub fn options(path: impl AsRef<str>) -> Self

Create a PathMatcher matcher to match for a OPTIONS request.

Source

pub fn trace(path: impl AsRef<str>) -> Self

Create a PathMatcher matcher to match for a TRACE request.

Source

pub fn and(self, matcher: HttpMatcher<State, Body>) -> Self

Add a HttpMatcher to match on top of the existing set of HttpMatcher matchers.

Source

pub fn or(self, matcher: HttpMatcher<State, Body>) -> Self

Create a HttpMatcher matcher to match as an alternative to the existing set of HttpMatcher matchers.

Source

pub fn negate(self) -> Self

Negate the current matcher

Trait Implementations§

Source§

impl<State, Body> Clone for HttpMatcher<State, Body>

Source§

fn clone(&self) -> Self

Returns a copy of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl<State, Body> Debug for HttpMatcher<State, Body>

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl<State, Body> Matcher<State, Request<Body>> for HttpMatcher<State, Body>
where State: Clone + Send + Sync + 'static, Body: Send + 'static,

Source§

fn matches( &self, ext: Option<&mut Extensions>, ctx: &Context<State>, req: &Request<Body>, ) -> bool

returns true on a match, false otherwise Read more
Source§

fn or<M>(self, other: M) -> impl Matcher<State, Request>
where Self: Sized, M: Matcher<State, Request>,

Provide an alternative matcher to match if the current one does not match.
Source§

fn and<M>(self, other: M) -> impl Matcher<State, Request>
where Self: Sized, M: Matcher<State, Request>,

Add another condition to match on top of the current one.
Source§

fn not(self) -> impl Matcher<State, Request>
where Self: Sized,

Negate the current condition.

Auto Trait Implementations§

§

impl<State, Body> !Freeze for HttpMatcher<State, Body>

§

impl<State, Body> !RefUnwindSafe for HttpMatcher<State, Body>

§

impl<State, Body> Send for HttpMatcher<State, Body>

§

impl<State, Body> Sync for HttpMatcher<State, Body>

§

impl<State, Body> Unpin for HttpMatcher<State, Body>

§

impl<State, Body> !UnwindSafe for HttpMatcher<State, Body>

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dst: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dst. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> FutureExt for T

Source§

fn with_context(self, otel_cx: Context) -> WithContext<Self>

Attaches the provided Context to this type, returning a WithContext wrapper. Read more
Source§

fn with_current_context(self) -> WithContext<Self>

Attaches the current Context to this type, returning a WithContext wrapper. Read more
Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<S, P, B, E>(self, other: P) -> And<T, P>
where T: Policy<S, B, E>, P: Policy<S, B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<S, P, B, E>(self, other: P) -> Or<T, P>
where T: Policy<S, B, E>, P: Policy<S, B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more