Expand description
§HTTP Client Module
Tanu’s HTTP client provides a wrapper around reqwest::Client with enhanced
logging and testing capabilities. It offers the same interface as reqwest::Client
while automatically capturing request and response logs for debugging and reporting.
§Key Features
- Automatic Logging: Captures all HTTP requests and responses
- Same API as reqwest: Drop-in replacement for familiar
reqwestusage - Integration with Assertions: Works seamlessly with tanu’s assertion macros
- Error Handling: Enhanced error types with context for better debugging
§Basic Usage
ⓘ
use tanu::{check_eq, http::Client};
#[tanu::test]
async fn test_api() -> eyre::Result<()> {
let client = Client::new();
let response = client
.get("https://api.example.com/users")
.header("accept", "application/json")
.send()
.await?;
check_eq!(200, response.status().as_u16());
let users: serde_json::Value = response.json().await?;
check!(users.is_array());
Ok(())
}Modules§
- header
- HTTP header types
Structs§
- Client
- Tanu’s HTTP client that provides enhanced testing capabilities.
- Log
- LogRequest
- LogResponse
- Method
- The Request Method (VERB)
- Request
Builder - Response
- HTTP response wrapper with enhanced testing capabilities.
- Status
Code - An HTTP status code (
status-codein RFC 9110 et al.). - Version
- Represents a version of the HTTP spec.