Struct httptest::ServerHandle
source · pub struct ServerHandle<'a> { /* private fields */ }
Expand description
A handle to a server. Expectations are inserted when the handle is dropped.
Methods from Deref<Target = Server>§
sourcepub fn addr(&self) -> SocketAddr
pub fn addr(&self) -> SocketAddr
Get the address the server is listening on.
sourcepub fn url(&self, path_and_query: &str) -> Uri
pub fn url(&self, path_and_query: &str) -> Uri
Get a fully formed url to the servers address.
If the server is listening on port 1234.
server.url("/foo?q=1") == "http://localhost:1234/foo?q=1"
sourcepub fn url_str(&self, path_and_query: &str) -> String
pub fn url_str(&self, path_and_query: &str) -> String
Get a fully formed url to the servers address as a String.
server.url_str(foo) == server.url(foo).to_string()
sourcepub fn expect(&self, expectation: Expectation)
pub fn expect(&self, expectation: Expectation)
Add a new expectation to the server.
sourcepub fn verify_and_clear(&mut self)
pub fn verify_and_clear(&mut self)
Verify all registered expectations. Panic if any are not met, then clear all expectations leaving the server running in a clean state.
Trait Implementations§
source§impl<'a> Debug for ServerHandle<'a>
impl<'a> Debug for ServerHandle<'a>
source§impl Deref for ServerHandle<'_>
impl Deref for ServerHandle<'_>
source§impl DerefMut for ServerHandle<'_>
impl DerefMut for ServerHandle<'_>
Auto Trait Implementations§
impl<'a> !RefUnwindSafe for ServerHandle<'a>
impl<'a> Send for ServerHandle<'a>
impl<'a> Sync for ServerHandle<'a>
impl<'a> Unpin for ServerHandle<'a>
impl<'a> !UnwindSafe for ServerHandle<'a>
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