pub struct TestServer { /* private fields */ }
Expand description

Test server controller

Implementations§

source§

impl TestServer

source

pub fn addr(&self) -> SocketAddr

Construct test server url

source

pub fn url(&self, uri: &str) -> String

Construct test server url

source

pub fn surl(&self, uri: &str) -> String

Construct test HTTPS server URL.

source

pub fn get<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create GET request

source

pub fn sget<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create HTTPS GET request

source

pub fn post<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create POST request

source

pub fn spost<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create HTTPS POST request

source

pub fn head<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create HEAD request

source

pub fn shead<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create HTTPS HEAD request

source

pub fn put<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create PUT request

source

pub fn sput<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create HTTPS PUT request

source

pub fn patch<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create PATCH request

source

pub fn spatch<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create HTTPS PATCH request

source

pub fn delete<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create DELETE request

source

pub fn sdelete<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create HTTPS DELETE request

source

pub fn options<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create OPTIONS request

source

pub fn soptions<S: AsRef<str>>(&self, path: S) -> ClientRequest

Create HTTPS OPTIONS request

source

pub fn request<S: AsRef<str>>(&self, method: Method, path: S) -> ClientRequest

Connect to test HTTP server

source

pub async fn load_body<S>( &mut self, response: ClientResponse<S> ) -> Result<Bytes, PayloadError>
where S: Stream<Item = Result<Bytes, PayloadError>> + Unpin + 'static,

source

pub async fn ws_at( &mut self, path: &str ) -> Result<Framed<impl AsyncRead + AsyncWrite, Codec>, WsClientError>

Connect to WebSocket server at a given path.

source

pub async fn ws( &mut self ) -> Result<Framed<impl AsyncRead + AsyncWrite, Codec>, WsClientError>

Connect to a WebSocket server.

source

pub fn client_headers(&mut self) -> Option<&mut HeaderMap>

Get default HeaderMap of Client.

Returns Some(&mut HeaderMap) when Client object is unique (No other clone of client exists at the same time).

source

pub async fn stop(&mut self)

Stop HTTP server.

Waits for spawned Server and System to (force) shutdown.

Trait Implementations§

source§

impl Drop for TestServer

source§

fn drop(&mut self)

Executes the destructor for this type. Read more

Auto Trait Implementations§

Blanket Implementations§

source§

impl<T> Any for T
where T: 'static + ?Sized,

source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
source§

impl<T> Borrow<T> for T
where T: ?Sized,

source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
source§

impl<T> From<T> for T

source§

fn from(t: T) -> T

Returns the argument unchanged.

§

impl<T> Instrument for T

§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided [Span], returning an Instrumented wrapper. Read more
§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
source§

impl<T, U> Into<U> for T
where U: From<T>,

source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

source§

impl<T> Same for T

§

type Output = T

Should always be Self
source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

§

type Error = Infallible

The type returned in the event of a conversion error.
source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a [WithDispatch] wrapper. Read more
§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a [WithDispatch] wrapper. Read more