Struct mockito::ServerGuard
source · pub struct ServerGuard { /* private fields */ }
Expand description
A handle around a pooled Server
object which dereferences to Server
.
Methods from Deref<Target = Server>§
sourcepub fn mock<P: Into<Matcher>>(&mut self, method: &str, path: P) -> Mock
pub fn mock<P: Into<Matcher>>(&mut self, method: &str, path: P) -> Mock
Initializes a mock with the given HTTP method
and path
.
The mock is enabled on the server only after calling the Mock::create
method.
Example
let mut s = mockito::Server::new();
let _m1 = s.mock("GET", "/");
let _m2 = s.mock("POST", "/users");
let _m3 = s.mock("DELETE", "/users?id=1");
sourcepub fn host_with_port(&self) -> String
pub fn host_with_port(&self) -> String
The host and port of the mock server.
Can be used with std::net::TcpStream
.
sourcepub async fn reset_async(&mut self)
pub async fn reset_async(&mut self)
Same as Server::reset
but async.