Features
- Simple, fluent API for making HTTP requests
- Function options pattern for configuration
- Context support for cancellation and timeouts
- Middleware support for request customization
- Generic response handling
- Built-in middleware implementations for common use cases
- Comprehensive test coverage
Basic Usage
Advanced Usage
Middleware
The client supports middleware for request customization:Request-specific options
You can add headers or other options to specific requests:POST requests with JSON body
Middleware Implementations
The package includes several built-in middleware implementations:AuthBearerMiddleware: Adds a Bearer token to the Authorization headerBasicAuthMiddleware: Adds basic authentication to the request
Custom Middleware
You can create your own middleware:Error Handling
The client returns comprehensive errors that can be unwrapped:Inbuilt Tracing
When using tracing alongside an http client, you can enable tracing usingResponse Helpers
TheResponse type provides helper methods:
Unmarshal(v interface{}): Decodes the response body into a structString(): Returns the response body as a stringIsSuccess(): Returns true if the status code is in the 2xx range