Struct tiny_http::TestRequest [−][src]
pub struct TestRequest { /* fields omitted */ }
Expand description
A simpler version of Request
that is useful for testing. No data actually goes anywhere.
By default, TestRequest
pretends to be an insecure GET request for the server root (/
)
with no headers. To create a TestRequest
with different parameters, use the builder pattern:
let request = TestRequest::new() .with_method(Method::Post) .with_path("/api/widgets") .with_body("42");
Then, convert the TestRequest
into a real Request
and pass it to the server under test:
let response = server.handle_request(request.into()); assert_eq!(response.status_code(), StatusCode(200));
Implementations
impl TestRequest
[src]
impl TestRequest
[src]pub fn new() -> Self
[src]
pub fn with_body(self, body: &'static str) -> Self
[src]
pub fn with_remote_addr(self, remote_addr: SocketAddr) -> Self
[src]
pub fn with_https(self) -> Self
[src]
pub fn with_method(self, method: Method) -> Self
[src]
pub fn with_path(self, path: &'static str) -> Self
[src]
pub fn with_http_version(self, version: HTTPVersion) -> Self
[src]
pub fn with_header(self, header: Header) -> Self
[src]
Trait Implementations
impl Default for TestRequest
[src]
impl Default for TestRequest
[src]impl From<TestRequest> for Request
[src]
impl From<TestRequest> for Request
[src]fn from(mock: TestRequest) -> Request
[src]
fn from(mock: TestRequest) -> Request
[src]Performs the conversion.