pub struct MockServer {
pub base: String,
/* private fields */
}Fields§
§base: StringImplementations§
Source§impl MockServer
impl MockServer
Sourcepub fn start(routes: Vec<Route>) -> Result<Self>
pub fn start(routes: Vec<Route>) -> Result<Self>
Static JSON routes; unmatched requests get 404 {"error":"unmocked"}.
Sourcepub fn start_static(
routes: Vec<(Option<String>, String, Reply)>,
) -> Result<Self>
pub fn start_static( routes: Vec<(Option<String>, String, Reply)>, ) -> Result<Self>
Static routes answered with full Replys (binary bodies, extra headers such as a
strong ETag, Reply::ignore_range, Reply::cut_after): (method, path, reply),
first match wins, None method matches any, query ignored; unmatched requests get 404.
Sourcepub fn start_with<R: Into<Reply>>(
handler: impl Fn(&Request, &str) -> R + Send + Sync + 'static,
) -> Result<Self>
pub fn start_with<R: Into<Reply>>( handler: impl Fn(&Request, &str) -> R + Send + Sync + 'static, ) -> Result<Self>
Dynamic handler: handler(request, base_url) answers every request. base_url
(http://127.0.0.1:<port>) lets a reply point the client back at the mock (a job’s
result URL). Return a Reply, or an Option<Reply> where None means 404. A
panicking handler yields a 500 instead of killing the server.
pub fn port(&self) -> u16
pub fn seen(&self) -> Vec<Seen>
pub fn close(&self)
Trait Implementations§
Source§impl Drop for MockServer
impl Drop 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 UnsafeUnpin 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