Crate asserhttp[][src]

Expand description

Allows fluent assertions for various http client responses. Supports surf and isahc.

It works for blocking or async client methods and for responses wrapped in Result.

Example

surf

use asserhttp::*;

#[async_std::test]
async fn sample_test() {
    surf::get("http://localhost/api/any").await.unwrap().expect_status_ok();
    // no need to call `.unwrap()` directly
    surf::get("http://localhost/api/any").await.expect_status_ed(200);
    surf::get("http://localhost/api/any").await.expect_status_ok();
    surf::get("http://localhost/api/any").await.expect_status_bad_request();
    surf::get("http://localhost/api/any").await.expect_status_internal_server_error();
    // and many more !
}

surf

use asserhttp::*;

#[async_std::test]
async fn sample_test() {
    isahc::get_async("http://localhost/api/any").await.unwrap().expect_status_ok();
    // no need to call `.unwrap()` directly
    isahc::get_async("http://localhost/api/any").await.expect_status_ed(200);
    isahc::get_async("http://localhost/api/any").await.expect_status_ok();
    isahc::get_async("http://localhost/api/any").await.expect_status_bad_request();
    isahc::get_async("http://localhost/api/any").await.expect_status_internal_server_error();
    // and many more !
}

Traits

For assertions on http response

For assertions on http response body

For assertions on http response headers

For assertions on http response status