Struct tiny_http::TestRequest
source ·
[−]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
Trait Implementations
Performs the conversion.
