// Package httpx provides a high-level HTTP client with composable middleware // for retry, circuit breaking, load balancing, structured logging, and more. // // The client is configured via functional options and assembled as a middleware // chain around a standard http.RoundTripper: // // Logging → User Middlewares → Retry → Circuit Breaker → Balancer → Transport // // # Quick start // // client := httpx.New( // httpx.WithBaseURL("https://api.example.com"), // httpx.WithTimeout(10 * time.Second), // httpx.WithRetry(), // httpx.WithCircuitBreaker(), // ) // defer client.Close() // // resp, err := client.Get(ctx, "/users/1") // // # Request builders // // NewJSONRequest and NewFormRequest create requests with appropriate // Content-Type headers and GetBody set for retry compatibility. // // # Error handling // // Failed requests return *httpx.Error with structured fields (Op, URL, // StatusCode). Sentinel errors ErrRetryExhausted, ErrCircuitOpen, and // ErrNoHealthy can be checked with errors.Is. // // # Sub-packages // // - middleware — client-side middleware (logging, auth, headers, recovery, request ID) // - retry — configurable retry with backoff and Retry-After support // - circuitbreaker — per-host circuit breaker (closed → open → half-open) // - balancer — client-side load balancing with health checking // - server — production HTTP server with router, middleware, and graceful shutdown package httpx