pub struct HttpRequestMatcher<B> { /* private fields */ }Expand description
Matches CanisterHttpRequests whose body can be deserialized and matched by B.
The type parameter B determines what kind of body is matched:
SingleJsonRpcMatcherfor single JSON-RPC requests (seeJsonRpcRequestMatcher)Vec<SingleJsonRpcMatcher>for batch JSON-RPC requests (seeBatchJsonRpcRequestMatcher)
Implementations§
Source§impl<B> HttpRequestMatcher<B>
impl<B> HttpRequestMatcher<B>
Sourcepub fn with_url(self, url: &str) -> Self
pub fn with_url(self, url: &str) -> Self
Mutates the matcher to match only requests with the given URL.
Sourcepub fn with_host(self, host: &str) -> Self
pub fn with_host(self, host: &str) -> Self
Mutates the matcher to match only requests whose URL has the given host.
Sourcepub fn with_request_headers(
self,
headers: Vec<(impl ToString, impl ToString)>,
) -> Self
pub fn with_request_headers( self, headers: Vec<(impl ToString, impl ToString)>, ) -> Self
Mutates the matcher to match requests with the given HTTP headers.
Sourcepub fn with_max_response_bytes(self, max_response_bytes: impl Into<u64>) -> Self
pub fn with_max_response_bytes(self, max_response_bytes: impl Into<u64>) -> Self
Mutates the matcher to match requests with the given max_response_bytes.
Source§impl HttpRequestMatcher<SingleJsonRpcMatcher>
impl HttpRequestMatcher<SingleJsonRpcMatcher>
Sourcepub fn with_method(method: impl Into<String>) -> Self
pub fn with_method(method: impl Into<String>) -> Self
Create a JsonRpcRequestMatcher that matches only JSON-RPC requests with the given method.
Sourcepub fn with_id(self, id: u64) -> Self
pub fn with_id(self, id: u64) -> Self
Mutates the JsonRpcRequestMatcher to match only requests whose JSON-RPC request ID is a
ConstantSizeId with the given value.
Sourcepub fn with_raw_id(self, id: Id) -> Self
pub fn with_raw_id(self, id: Id) -> Self
Mutates the JsonRpcRequestMatcher to match only requests whose JSON-RPC request ID is an
Id with the given value.
Sourcepub fn with_params(self, params: impl Into<Value>) -> Self
pub fn with_params(self, params: impl Into<Value>) -> Self
Mutates the JsonRpcRequestMatcher to match only requests with the given JSON-RPC request
parameters.
Source§impl HttpRequestMatcher<Vec<SingleJsonRpcMatcher>>
impl HttpRequestMatcher<Vec<SingleJsonRpcMatcher>>
Sourcepub fn batch(matchers: Vec<SingleJsonRpcMatcher>) -> Self
pub fn batch(matchers: Vec<SingleJsonRpcMatcher>) -> Self
Create a BatchJsonRpcRequestMatcher that matches a batch JSON-RPC request
containing exactly the given individual matchers, matched pairwise in order.
Trait Implementations§
Source§impl CanisterHttpRequestMatcher for HttpRequestMatcher<SingleJsonRpcMatcher>
impl CanisterHttpRequestMatcher for HttpRequestMatcher<SingleJsonRpcMatcher>
Source§fn matches(&self, request: &CanisterHttpRequest) -> bool
fn matches(&self, request: &CanisterHttpRequest) -> bool
CanisterHttpRequest matches.Source§impl CanisterHttpRequestMatcher for HttpRequestMatcher<Vec<SingleJsonRpcMatcher>>
impl CanisterHttpRequestMatcher for HttpRequestMatcher<Vec<SingleJsonRpcMatcher>>
Source§fn matches(&self, request: &CanisterHttpRequest) -> bool
fn matches(&self, request: &CanisterHttpRequest) -> bool
CanisterHttpRequest matches.Source§impl<B: Clone> Clone for HttpRequestMatcher<B>
impl<B: Clone> Clone for HttpRequestMatcher<B>
Source§fn clone(&self) -> HttpRequestMatcher<B>
fn clone(&self) -> HttpRequestMatcher<B>
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl<B> Freeze for HttpRequestMatcher<B>where
B: Freeze,
impl<B> RefUnwindSafe for HttpRequestMatcher<B>where
B: RefUnwindSafe,
impl<B> Send for HttpRequestMatcher<B>where
B: Send,
impl<B> Sync for HttpRequestMatcher<B>where
B: Sync,
impl<B> Unpin for HttpRequestMatcher<B>where
B: Unpin,
impl<B> UnsafeUnpin for HttpRequestMatcher<B>where
B: UnsafeUnpin,
impl<B> UnwindSafe for HttpRequestMatcher<B>where
B: UnwindSafe,
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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