Struct apisdk::MockServer
source · pub struct MockServer { /* private fields */ }
Expand description
This middleware is used to mock the response
§Examples
§mock single request
let req = client.get("/api/path").await?;
let req = req.with_extension(MockServer::new(|r| {
// return a fake response by using serde_json::Value
Ok(json!({
"key": "value"
}))
}));
let res = send!(req).await
§mock all requests
let client = XxxApi::builder().with_initialiser(MockServer::new(|r| {
// return a fake response by using serde_json::Value
Ok(json!({
"key": "value"
}))
})).build();
Implementations§
Trait Implementations§
source§impl Clone for MockServer
impl Clone for MockServer
source§fn clone(&self) -> MockServer
fn clone(&self) -> MockServer
Returns a copy of the value. Read more
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source
. Read moresource§impl RequestInitialiser for MockServer
impl RequestInitialiser for MockServer
Mock all requests
fn init(&self, req: RequestBuilder) -> RequestBuilder
source§impl Responder for MockServer
impl Responder for MockServer
Auto Trait Implementations§
impl Freeze for MockServer
impl !RefUnwindSafe for MockServer
impl Send for MockServer
impl Sync for MockServer
impl Unpin for MockServer
impl !UnwindSafe for MockServer
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
source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)