{"id":13502946,"url":"https://github.com/beltram/asserhttp","last_synced_at":"2025-07-15T06:32:18.617Z","repository":{"id":36962426,"uuid":"372879640","full_name":"beltram/asserhttp","owner":"beltram","description":"Fluent http assertions","archived":false,"fork":false,"pushed_at":"2024-04-18T12:15:48.000Z","size":523,"stargazers_count":36,"open_issues_count":7,"forks_count":3,"subscribers_count":3,"default_branch":"main","last_synced_at":"2024-10-31T11:39:27.683Z","etag":null,"topics":[],"latest_commit_sha":null,"homepage":null,"language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"apache-2.0","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/beltram.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null}},"created_at":"2021-06-01T15:34:29.000Z","updated_at":"2024-03-25T08:02:24.000Z","dependencies_parsed_at":"2023-02-16T22:46:03.598Z","dependency_job_id":"5584529d-b45a-4125-9a05-84c130280576","html_url":"https://github.com/beltram/asserhttp","commit_stats":{"total_commits":333,"total_committers":6,"mean_commits":55.5,"dds":"0.45945945945945943","last_synced_commit":"9541c546426afe0c3693f4bf3b17ade0936d820f"},"previous_names":[],"tags_count":23,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beltram%2Fasserhttp","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beltram%2Fasserhttp/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beltram%2Fasserhttp/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/beltram%2Fasserhttp/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/beltram","download_url":"https://codeload.github.com/beltram/asserhttp/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":226022747,"owners_count":17561332,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":[],"created_at":"2024-07-31T22:02:31.334Z","updated_at":"2024-11-23T09:17:54.674Z","avatar_url":"https://github.com/beltram.png","language":"Rust","funding_links":[],"categories":["Rust"],"sub_categories":[],"readme":"\u003ch1 align=\"center\"\u003easserhttp\u003c/h1\u003e\n\u003cdiv align=\"center\"\u003e\n \u003cstrong\u003e\n   Fluent http response assertions\n \u003c/strong\u003e\n\u003c/div\u003e\n\u003cbr /\u003e\n\u003cdiv align=\"center\"\u003e\n  \u003c!-- Crates version --\u003e\n  \u003ca href=\"https://crates.io/crates/asserhttp\"\u003e\n    \u003cimg src=\"https://img.shields.io/crates/v/asserhttp.svg?style=flat-square\"\n    alt=\"Crates.io version\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Minimum Supported Rust Version --\u003e\n  \u003ca href=\"rust: 1.60.0+\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/rust-1.60.0%2B-green.svg\"\n    alt=\"Crates.io version\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- docs.rs docs --\u003e\n  \u003ca href=\"https://docs.rs/asserhttp\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/docs-latest-blue.svg?style=flat-square\"\n      alt=\"docs.rs docs\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- license --\u003e\n  \u003ca href=\"LICENSE\"\u003e\n    \u003cimg src=\"https://img.shields.io/badge/license-Apache_2-blue.svg?style=flat-square\"\n      alt=\"Apache 2\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- CI status --\u003e\n  \u003ca href=\"https://github.com/beltram/asserhttp/actions\"\u003e\n    \u003cimg src=\"https://github.com/beltram/asserhttp/workflows/ci/badge.svg?style=flat-square\"\n      alt=\"ci\" /\u003e\n  \u003c/a\u003e\n  \u003c!-- Code coverage --\u003e\n  \u003ca href=\"https://coveralls.io/github/beltram/asserhttp?branch=main\"\u003e\n    \u003cimg src=\"https://coveralls.io/repos/github/beltram/asserhttp/badge.svg?branch=main\" alt=\"coverage\" /\u003e\n  \u003c/a\u003e\n\u003c/div\u003e\n\u003cbr/\u003e\n\nA standard trait for doing fluent assertions over many http client response. Currently, supports\n[actix-web](https://actix.rs/docs/testing/), [rocket](https://github.com/SergioBenitez/Rocket),\n[reqwest](https://github.com/seanmonstar/reqwest), [hyper](https://github.com/hyperium/hyper),\n[axum](https://github.com/tokio-rs/axum), [awc](https://docs.rs/awc) (Actix Web Client),\n[surf](https://github.com/http-rs/surf), [ureq](https://github.com/algesten/ureq)\nand [isahc](https://github.com/sagebind/isahc).\n\n## Getting started\n\nAdd it to your `Cargo.toml`\n\n```toml\nasserhttp = { version = \"0.6.1\", features = [\"reqwest\"] }\n#                             or features = [\"hyper\"]\n#                             or features = [\"actix\"]\n#                             or features = [\"axum\"]\n#                             or features = [\"actix-web-client\"]\n#                             or features = [\"rocket\"]\n#                             or features = [\"surf\"]\n#                             or features = [\"ureq\"]\n#                             or features = [\"isahc\"]\n```\n\nThen use it in your tests, for example on [actix-web](https://actix.rs/docs/testing/),\n\n```rust\nuse actix_web::{App, HttpResponse, test::{call_service, init_service, TestRequest}, web};\nuse asserhttp::*;\n\n#[actix_web::test]\nasync fn sample_test() {\n    let app = App::new().route(\"/\", web::get().to(|| async { HttpResponse::Ok().body(json!({\"a\": \"b\"})) }));\n    call_service(\u0026mut init_service(app).await, TestRequest::get().to_request()).await\n        .expect_status_ok()\n        .expect_content_type_json()\n        .expect_body_json_eq(json!({\"a\": \"b\"}));\n}\n```\n\nor on [reqwest](https://github.com/seanmonstar/reqwest)\n\n```rust\nuse reqwest;\nuse asserhttp::*;\n\n#[tokio::test]\nasync fn my_test() {\n    reqwest::get(\"http://localhost\").await\n        .expect_status_ok()\n        .expect_content_type_json()\n        .expect_body_json_eq(json!({\"name\": \"jdoe\"}));\n}\n```\n\n## Customize\n\nYou don't like the asserhttp methods name ? That's fine, you can define yours. Define you own trait and use asserhttp \nmethods to define your own ! \n\nAs simple as this:\n\n```rust\nasserhttp::asserhttp_customize!(MyHttpDsl);\n\npub trait MyHttpDsl\u003cT\u003e: asserhttp::Asserhttp\u003cT\u003e {\n    fn is_status_ok(\u0026mut self) -\u003e \u0026mut T {\n        self.expect_status_ok()\n    }\n    fn is_json(\u0026mut self) -\u003e \u0026mut T {\n        self.expect_content_type_json()\n    }\n    fn has_body(\u0026mut self) -\u003e \u0026mut T { self.expect_body_present() }\n}\n```\n\n## gRPC\n\nAsserting gRPC is also supported with a [tonic](https://github.com/hyperium/tonic) client. Simply turn on the `tonic` \nfeature and use it like this:\n\n```rust\nuse asserhttp::grpc::*;\n\n#[tokio::main]\nasync fn main() {\n    // success\n    client.call_svc(tonic::Request::new(Payload)).await.expect_status_ok().expect_body(Payload);\n    // error\n    client.call_svc(tonic::Request::new(Payload)).await.expect_status_error(Code::NotFound);\n}\n```\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeltram%2Fasserhttp","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fbeltram%2Fasserhttp","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fbeltram%2Fasserhttp/lists"}