Struct actix_http::test::TestRequest [−][src]
pub struct TestRequest(_);Expand description
Test Request builder
ⓘ
use actix_web::test::TestRequest;
fn index(req: &HttpRequest) -> Response {
if let Some(hdr) = req.headers().get(header::CONTENT_TYPE) {
Response::Ok().into()
} else {
Response::BadRequest().into()
}
}
let resp = TestRequest::default().insert_header("content-type", "text/plain")
.run(&index)
.unwrap();
assert_eq!(resp.status(), StatusCode::OK);
let resp = TestRequest::default().run(&index).unwrap();
assert_eq!(resp.status(), StatusCode::BAD_REQUEST);Implementations
Create a default TestRequest and then set its URI.
Insert a header, replacing any that were set with an equivalent field name.
Append a header, keeping any that were set with an equivalent field name.
Set request payload.
Trait Implementations
Returns the “default value” for a type. Read more
Auto Trait Implementations
impl !RefUnwindSafe for TestRequest
impl !Send for TestRequest
impl !Sync for TestRequest
impl Unpin for TestRequest
impl !UnwindSafe for TestRequest
Blanket Implementations
Mutably borrows from an owned value. Read more
pub fn vzip(self) -> V
Attaches the provided Subscriber to this type, returning a
WithDispatch wrapper. Read more
Attaches the current default Subscriber to this type, returning a
WithDispatch wrapper. Read more