requests

package module
v0.2.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 8, 2026 License: MIT Imports: 17 Imported by: 0

README

Go Requests

Language Last Commit CI codecov Benchmark Go Reference Go Report Card

English | 简体中文

Go Requests is a modern, type-safe HTTP client library for Go, inspired by Python's Requests library. It leverages Go 1.18+ generics to provide compile-time type safety and a fluent API for building HTTP requests.

Features

  • Type-Safe Generic Methods: GetJSON[T], PostJSON[T], etc. return Result[T] for automatic response parsing
  • Fluent Request Builder: Chain methods to construct complex requests with NewGet, NewPost, etc.
  • Unified Result Type: Result[T] wraps both parsed data and response metadata
  • Middleware Support: Add cross-cutting concerns like logging, authentication, retry
  • Session Management: Connection pooling, cookie persistence, default headers
  • Pluggable Codecs: JSON, XML built-in with custom codec support
  • Retry Mechanism: Configurable retry policies with exponential backoff
  • Request/Response Hooks: Observe lifecycle events for logging and metrics
  • File Upload: Multipart uploads with progress tracking
  • HTTP/2 Support: Automatic HTTP/2 with fallback to HTTP/1.1
  • Connection Pool Optimization: Configurable pool sizes and idle timeouts
  • High Performance: Object pooling, zero-copy optimizations, close to net/http performance

Install

go get github.com/sunerpy/requests

Quick Start

Simple GET Request
import "github.com/sunerpy/requests"

// Basic GET request
resp, err := requests.Get("https://api.github.com")
if err != nil {
    log.Fatal(err)
}
fmt.Println("Status:", resp.StatusCode)
fmt.Println("Body:", resp.Text())

// GET with query parameters using options
resp, err := requests.Get("https://api.github.com/search/repos",
    requests.WithQuery("q", "golang"),
    requests.WithQuery("sort", "stars"),
)
Generic JSON Response with Result[T]
type User struct {
    ID   int    `json:"id"`
    Name string `json:"name"`
}

// GetJSON returns Result[T] which wraps both data and response metadata
result, err := requests.GetJSON[User]("https://api.example.com/user/1")
if err != nil {
    log.Fatal(err)
}

// Access parsed data
fmt.Printf("User: %+v\n", result.Data())

// Access response metadata
fmt.Printf("Status: %d\n", result.StatusCode())
fmt.Printf("Success: %v\n", result.IsSuccess())
fmt.Printf("Headers: %v\n", result.Headers())
POST with JSON Body
type CreateUser struct {
    Name  string `json:"name"`
    Email string `json:"email"`
}

type UserResponse struct {
    ID int `json:"id"`
}

// PostJSON returns Result[T]
result, err := requests.PostJSON[UserResponse](
    "https://api.example.com/users",
    CreateUser{Name: "John", Email: "[email protected]"},
)
if err != nil {
    log.Fatal(err)
}

fmt.Printf("Created user ID: %d\n", result.Data().ID)
fmt.Printf("Status: %d\n", result.StatusCode())
Using Request Builder
// Use convenience constructors for common methods
req, err := requests.NewPost("https://api.example.com/users").
    WithHeader("X-Custom-Header", "value").
    WithQuery("version", "v2").
    WithJSON(map[string]string{"name": "John"}).
    WithTimeout(10 * time.Second).
    Build()

// Or use NewRequestBuilder for any method
req, err := requests.NewRequestBuilder(requests.MethodPatch, "https://api.example.com/users/1").
    WithJSON(map[string]string{"name": "Jane"}).
    Build()

// Execute with DoJSON for automatic JSON parsing
result, err := requests.DoJSON[UserResponse](
    requests.NewPost("https://api.example.com/users").
        WithJSON(CreateUser{Name: "John", Email: "[email protected]"}),
)
Using Request Options
// Add headers, query params, auth, etc. using variadic options
resp, err := requests.Get("https://api.example.com/data",
    requests.WithHeader("X-Custom-Header", "value"),
    requests.WithQuery("page", "1"),
    requests.WithBearerToken("my-token"),
    requests.WithTimeout(10 * time.Second),
)

Advanced Usage

Session with Defaults
session := requests.NewSession().
    WithBaseURL("https://api.example.com").
    WithTimeout(30 * time.Second).
    WithHeader("Authorization", "Bearer token").
    WithHTTP2(true).
    WithMaxIdleConns(100)

defer session.Close()

// Build request using the new Builder API
req, _ := requests.NewGet("/users").Build()

// Execute with session
resp, err := session.Do(req)
Using Context for Timeout and Cancellation
import "context"

// Create a context with timeout
ctx, cancel := context.WithTimeout(context.Background(), 5*time.Second)
defer cancel()

session := requests.NewSession()
defer session.Close()

req, _ := requests.NewGet("https://api.example.com/data").Build()

// Execute with context - respects timeout and cancellation
resp, err := session.DoWithContext(ctx, req)
if err != nil {
    if err == context.DeadlineExceeded {
        log.Println("Request timed out")
    } else if err == context.Canceled {
        log.Println("Request was cancelled")
    }
    return
}
fmt.Println("Response:", resp.Text())
Context Cancellation Example
ctx, cancel := context.WithCancel(context.Background())

// Cancel the request after 2 seconds
go func() {
    time.Sleep(2 * time.Second)
    cancel()
}()

session := requests.NewSession()
defer session.Close()

req, _ := requests.NewGet("https://api.example.com/slow-endpoint").Build()
resp, err := session.DoWithContext(ctx, req)
if err != nil {
    // Handle cancellation
    log.Printf("Request cancelled: %v", err)
}
Session with Retry Policy
session := requests.NewSession().
    WithBaseURL("https://api.example.com").
    WithTimeout(30 * time.Second).
    WithRetry(requests.RetryPolicy{
        MaxAttempts:     3,
        InitialInterval: 100 * time.Millisecond,
        MaxInterval:     5 * time.Second,
        Multiplier:      2.0,
        RetryIf: func(resp *requests.Response, err error) bool {
            if err != nil {
                return true // Retry on network errors
            }
            // Retry on 5xx errors and 429 Too Many Requests
            return resp.StatusCode >= 500 || resp.StatusCode == 429
        },
    })

defer session.Close()

req, _ := requests.NewGet("/users").Build()
resp, err := session.Do(req) // Will automatically retry on failure
Session with Middleware
// Create a logging middleware
loggingMiddleware := requests.MiddlewareFunc(func(req *requests.Request, next requests.Handler) (*requests.Response, error) {
    start := time.Now()
    log.Printf("Request: %s %s", req.Method, req.URL)
    
    resp, err := next(req)
    
    duration := time.Since(start)
    if resp != nil {
        log.Printf("Response: %d in %v", resp.StatusCode, duration)
    }
    return resp, err
})

// Create session with middleware
session := requests.NewSession().
    WithBaseURL("https://api.example.com").
    WithMiddleware(loggingMiddleware)

defer session.Close()

req, _ := requests.NewGet("/users").Build()
resp, err := session.Do(req) // Middleware will log request/response
Middleware
// Logging middleware
loggingMiddleware := requests.MiddlewareFunc(func(req *requests.Request, next requests.Handler) (*requests.Response, error) {
    log.Printf("Request: %s %s", req.Method, req.URL)
    resp, err := next(req)
    if resp != nil {
        log.Printf("Response: %d", resp.StatusCode)
    }
    return resp, err
})

chain := requests.NewMiddlewareChain(loggingMiddleware)
Retry Policy
policy := requests.ExponentialRetryPolicy(3, 100*time.Millisecond, 10*time.Second)

executor := requests.NewRetryExecutor(policy)

resp, err := executor.Execute(nil, func() (*requests.Response, error) {
    return requests.Get("https://api.example.com/data")
})
Request/Response Hooks
hooks := requests.NewHooks()

// Log all requests
hooks.OnRequest(func(req *requests.Request) {
    log.Printf("Sending: %s %s", req.Method, req.URL)
})

// Log all responses with duration
hooks.OnResponse(func(req *requests.Request, resp *requests.Response, duration time.Duration) {
    log.Printf("Received: %d in %v", resp.StatusCode, duration)
})

// Log errors
hooks.OnError(func(req *requests.Request, err error, duration time.Duration) {
    log.Printf("Error: %v", err)
})
File Upload
import "github.com/sunerpy/requests/url"

upload, err := url.NewFileUpload("file", "/path/to/file.pdf")
if err != nil {
    log.Fatal(err)
}

upload.WithProgress(func(uploaded, total int64) {
    fmt.Printf("Progress: %d/%d (%.1f%%)\n", uploaded, total, float64(uploaded)/float64(total)*100)
})
Custom Codec
import "github.com/sunerpy/requests/codec"

// Register custom codec
type YAMLCodec struct{}

func (c *YAMLCodec) Encode(v any) ([]byte, error) { /* ... */ }
func (c *YAMLCodec) Decode(data []byte, v any) error { /* ... */ }
func (c *YAMLCodec) ContentType() string { return "application/yaml" }

codec.Register("application/yaml", &YAMLCodec{})

API Reference

Package requests
Function Description
Get(url, opts...) Send GET request
Post(url, body, opts...) Send POST request with body
Put(url, body, opts...) Send PUT request with body
Delete(url, opts...) Send DELETE request
Patch(url, body, opts...) Send PATCH request with body
Head(url, opts...) Send HEAD request
Options(url, opts...) Send OPTIONS request
GetJSON[T](url, opts...) GET with JSON parsing, returns (Result[T], error)
PostJSON[T](url, data, opts...) POST JSON, returns (Result[T], error)
PutJSON[T](url, data, opts...) PUT JSON, returns (Result[T], error)
DeleteJSON[T](url, opts...) DELETE with JSON parsing, returns (Result[T], error)
PatchJSON[T](url, data, opts...) PATCH JSON, returns (Result[T], error)
GetString(url, opts...) GET and return body as string
GetBytes(url, opts...) GET and return body as bytes
DoJSON[T](builder) Execute builder and parse JSON response
NewSession() Create new session
DefaultSession() Get the default session
Session Methods
Method Description
Do(req) Execute request
DoWithContext(ctx, req) Execute request with context (supports timeout/cancellation)
Clone() Create a copy of the session
Close() Close the session and release resources
Clear() Reset session to default state
Session Configuration Methods
Method Description
WithBaseURL(url) Set base URL for all requests
WithTimeout(duration) Set request timeout
WithProxy(url) Set proxy URL
WithDNS(servers) Set custom DNS servers
WithHeader(key, value) Add default header
WithHeaders(map) Add multiple default headers
WithBasicAuth(user, pass) Set basic authentication
WithBearerToken(token) Set bearer token
WithHTTP2(enabled) Enable/disable HTTP/2
WithKeepAlive(enabled) Enable/disable keep-alive
WithMaxIdleConns(n) Set max idle connections
WithIdleTimeout(duration) Set idle connection timeout
WithRetry(policy) Set retry policy
WithMiddleware(m) Add middleware
WithCookieJar(jar) Set cookie jar
Request Builder
Function Description
NewGet(url) Create GET request builder
NewPost(url) Create POST request builder
NewPut(url) Create PUT request builder
NewDeleteBuilder(url) Create DELETE request builder
NewPatch(url) Create PATCH request builder
NewRequestBuilder(method, url) Create request builder with any method
Result[T] Methods
Method Description
Data() Get parsed response data of type T
Response() Get underlying Response object
StatusCode() Get HTTP status code
Headers() Get response headers
IsSuccess() Check if status is 2xx
IsError() Check if status is 4xx or 5xx
Cookies() Get response cookies
Request Options
Option Description
WithHeader(key, value) Add a header
WithHeaders(map) Add multiple headers
WithQuery(key, value) Add a query parameter
WithQueryParams(map) Add multiple query parameters
WithBasicAuth(user, pass) Set basic authentication
WithBearerToken(token) Set bearer token
WithTimeout(duration) Set request timeout
WithContentType(type) Set Content-Type header
WithContext(ctx) Set request context
WithAccept(type) Set Accept header

Migration Guide

From v1.x to v2.x
  1. Result[T] Type: Generic methods now return (Result[T], error) instead of (T, *Response, error)

    // Old
    user, resp, err := requests.GetJSONWithResponse[User](url)
    
    // New
    result, err := requests.GetJSON[User](url)
    user := result.Data()
    statusCode := result.StatusCode()
    
  2. Request Builder: Use NewGet, NewPost, etc. instead of NewRequest(method, url, params, body)

    // Old
    req, err := requests.NewRequest(requests.MethodGet, url, params, nil)
    
    // New
    req, err := requests.NewGet(url).WithQuery("key", "value").Build()
    
  3. Removed Methods: *WithResponse methods are removed, use Result[T] instead

  4. Single Import: Import only github.com/sunerpy/requests for most use cases

Contributing

Contributions are welcome! Please:

  1. Fork this repository
  2. Create a feature branch
  3. Make your changes with tests
  4. Submit a pull request

Performance

The library is optimized for high performance with:

  • Object Pooling: RequestBuilder, RequestConfig, FastValues pools to reduce allocations
  • Header Ownership Transfer: Avoids unnecessary cloning operations
  • Response Buffer Pool: Tiered buffer pools (4KB/32KB) for response reading
  • Close to net/http: Only ~6 more allocations than raw net/http
BenchmarkBasicRequests/NetHTTP_Get     40μs, 69 allocs, 6.3KB
BenchmarkBasicRequests/Requests_Get    44μs, 75 allocs, 6.3KB  (only +6 allocs)

For performance-critical code, use FastValues for URL parameter building:

import "github.com/sunerpy/requests/url"

// Lock-free FastValues for single-threaded scenarios
fv := url.AcquireFastValues()
defer url.ReleaseFastValues(fv)
fv.Add("page", "1")
fv.Add("limit", "10")

See Performance Optimization Guide for details.

Documentation

For detailed documentation, see:

Project Structure

requests/
├── internal/           # Internal packages (not for external use)
│   ├── client/         # HTTP client core implementation
│   ├── models/         # Internal data models
│   └── utils/          # Internal utilities
├── codec/              # Encoder/decoder implementations
├── url/                # URL utilities and file upload
├── docs/               # Documentation
│   ├── guides/         # User guides
│   └── examples/       # Code examples
├── test/               # Benchmark tests
├── example/            # Example application
├── session.go          # Session management
├── methods.go          # HTTP method functions
├── types.go            # Type exports
└── Makefile            # Build automation

License

MIT License - see LICENSE for details.

Documentation

Overview

Package requests provides a simple and easy-to-use HTTP client library for Go.

Index

Constants

View Source
const (
	MethodGet     = client.MethodGet
	MethodPost    = client.MethodPost
	MethodPut     = client.MethodPut
	MethodDelete  = client.MethodDelete
	MethodPatch   = client.MethodPatch
	MethodHead    = client.MethodHead
	MethodOptions = client.MethodOptions
	MethodConnect = client.MethodConnect
	MethodTrace   = client.MethodTrace
)

HTTP methods as constants - re-exported from client package.

Variables

View Source
var (
	WithTimeout = client.WithTimeout
	// WithHeader adds a single header to the request.
	WithHeader = client.WithHeader
	// WithHeaders adds multiple headers to the request.
	WithHeaders = client.WithHeaders
	// WithQuery adds a single query parameter.
	WithQuery = client.WithQuery
	// WithQueryParams adds multiple query parameters.
	WithQueryParams = client.WithQueryParams
	// WithBasicAuth adds basic authentication.
	WithBasicAuth = client.WithBasicAuth
	// WithBearerToken adds bearer token authentication.
	WithBearerToken = client.WithBearerToken
	// WithContext sets the request context.
	WithContext = client.WithContext
	// WithContentType sets the Content-Type header.
	WithContentType = client.WithContentType
	// WithAccept sets the Accept header.
	WithAccept = client.WithAccept
	// ============================================================================
	// Middleware and Hooks
	// ============================================================================
	// NewMiddlewareChain creates a new middleware chain.
	NewMiddlewareChain = client.NewMiddlewareChain
	// NewHooks creates a new Hooks instance.
	NewHooks = client.NewHooks
	// NewMetricsHook creates a new metrics hook.
	NewMetricsHook = client.NewMetricsHook
	// HeaderMiddleware creates middleware that adds headers.
	HeaderMiddleware = client.HeaderMiddleware
	// HooksMiddleware creates middleware from hooks.
	HooksMiddleware = client.HooksMiddleware
	// ============================================================================
	// Retry
	// ============================================================================
	// NewRetryExecutor creates a new retry executor.
	NewRetryExecutor = client.NewRetryExecutor
	// NoRetryPolicy returns a policy that never retries.
	NoRetryPolicy = client.NoRetryPolicy
	// LinearRetryPolicy returns a policy with linear backoff.
	LinearRetryPolicy = client.LinearRetryPolicy
	// ExponentialRetryPolicy returns a policy with exponential backoff.
	ExponentialRetryPolicy = client.ExponentialRetryPolicy
	// RetryOn5xx returns a condition that retries on 5xx errors.
	RetryOn5xx = client.RetryOn5xx
	// RetryOnNetworkError returns a condition that retries on network errors.
	RetryOnNetworkError = client.RetryOnNetworkError
	// RetryOnStatusCodes returns a condition that retries on specific status codes.
	RetryOnStatusCodes = client.RetryOnStatusCodes
	// CombineRetryConditions combines multiple retry conditions.
	CombineRetryConditions = client.CombineRetryConditions
)

============================================================================ Request Options ============================================================================ WithTimeout sets the request timeout.

View Source
var (
	IsTimeout = client.IsTimeout
	// IsConnectionError checks if an error is a connection error.
	IsConnectionError = client.IsConnectionError
	// IsResponseError checks if an error is a response error.
	IsResponseError = client.IsResponseError
	// IsTemporary checks if an error is temporary.
	IsTemporary = client.IsTemporary
)

============================================================================ Error Helpers ============================================================================ IsTimeout checks if an error is a timeout error.

Functions

func AcquireSession added in v0.1.0

func AcquireSession() client.Session

AcquireSession gets a Session from the pool. Remember to call ReleaseSession when done.

func DefaultSession added in v0.1.0

func DefaultSession() client.Session

DefaultSession returns the default session.

func GetBytes added in v0.1.0

func GetBytes(baseURL string, opts ...client.RequestOption) ([]byte, error)

GetBytes sends a GET request and returns the response body as bytes.

func GetString added in v0.1.0

func GetString(baseURL string, opts ...client.RequestOption) (string, error)

============================================================================ Convenience Functions ============================================================================ GetString sends a GET request and returns the response body as a string.

func GetTransport added in v0.1.0

func GetTransport(enableHTTP2 bool) *http.Transport

GetTransport returns a transport from the pool.

func IsHTTP2Enabled added in v0.1.0

func IsHTTP2Enabled() bool

IsHTTP2Enabled returns the global HTTP/2 enabled state.

func NewSession

func NewSession() client.Session

NewSession creates a new Session with default settings.

func PutTransport added in v0.1.0

func PutTransport(transport *http.Transport)

PutTransport returns a transport to the pool.

func ReleaseSession added in v0.1.0

func ReleaseSession(sess client.Session)

ReleaseSession returns a Session to the pool.

func SetHTTP2Enabled

func SetHTTP2Enabled(enabled bool)

SetHTTP2Enabled sets the global HTTP/2 enabled state.

Types

type BasicAuth added in v0.2.0

type BasicAuth = client.BasicAuth

BasicAuth holds basic authentication credentials.

type Client added in v0.1.0

type Client = client.Client

Client is the core HTTP client interface. It provides Do, DoWithContext, and Clone methods.

type ConnectionError added in v0.1.0

type ConnectionError = client.ConnectionError

Error types

type DecodeError added in v0.1.0

type DecodeError = client.DecodeError

Error types

type EncodeError added in v0.1.0

type EncodeError = client.EncodeError

Error types

type HTTPClient added in v0.1.0

type HTTPClient = client.HTTPClient

HTTPClient is the interface for executing HTTP requests.

type Handler added in v0.1.0

type Handler = client.Handler

Handler is a function that processes a request and returns a response.

type Hooks added in v0.1.0

type Hooks = client.Hooks

Hooks provides request/response lifecycle hooks.

type Method added in v0.1.0

type Method = client.Method

Method is an alias for client.Method - represents an HTTP method.

type Middleware added in v0.1.0

type Middleware = client.Middleware

Middleware is the interface for request/response middleware.

type MiddlewareChain added in v0.1.0

type MiddlewareChain = client.MiddlewareChain

MiddlewareChain manages a chain of middleware.

type MiddlewareFunc added in v0.2.0

type MiddlewareFunc = client.MiddlewareFunc

MiddlewareFunc is a function adapter for Middleware interface.

type Request added in v0.1.0

type Request = client.Request

Request is an alias for client.Request - the unified request type. Use NewRequestBuilder or convenience constructors (NewGet, NewPost, etc.) to create requests.

type RequestBuilder added in v0.1.0

type RequestBuilder = client.RequestBuilder

RequestBuilder provides a fluent interface for building HTTP requests.

func NewDeleteBuilder added in v0.1.0

func NewDeleteBuilder(rawURL string) *RequestBuilder

NewDelete creates a new DELETE request builder.

func NewGet added in v0.1.0

func NewGet(rawURL string) *RequestBuilder

NewGet creates a new GET request builder.

func NewPatch added in v0.1.0

func NewPatch(rawURL string) *RequestBuilder

NewPatch creates a new PATCH request builder.

func NewPost added in v0.1.0

func NewPost(rawURL string) *RequestBuilder

NewPost creates a new POST request builder.

func NewPut added in v0.1.0

func NewPut(rawURL string) *RequestBuilder

NewPut creates a new PUT request builder.

func NewRequestBuilder added in v0.1.0

func NewRequestBuilder(method Method, rawURL string) *RequestBuilder

============================================================================ RequestBuilder Constructors ============================================================================ NewRequestBuilder creates a new RequestBuilder with the specified method and URL.

type RequestError added in v0.1.0

type RequestError = client.RequestError

Error types

type RequestOption added in v0.1.0

type RequestOption = client.RequestOption

RequestOption is a function that modifies request configuration.

type Response added in v0.1.0

type Response = models.Response

Response represents an HTTP response. This is the unified response type used throughout the library.

func Delete

func Delete(baseURL string, opts ...client.RequestOption) (*Response, error)

Delete sends a DELETE request and returns the response.

func Get

func Get(baseURL string, opts ...client.RequestOption) (*Response, error)

============================================================================ Basic HTTP Methods (with variadic options) ============================================================================ Get sends a GET request and returns the response.

func Head(baseURL string, opts ...client.RequestOption) (*Response, error)

Head sends a HEAD request and returns the response.

func Options added in v0.1.0

func Options(baseURL string, opts ...client.RequestOption) (*Response, error)

Options sends an OPTIONS request and returns the response.

func Patch

func Patch(baseURL string, body any, opts ...client.RequestOption) (*Response, error)

Patch sends a PATCH request with optional body and returns the response.

func Post

func Post(baseURL string, body any, opts ...client.RequestOption) (*Response, error)

Post sends a POST request with optional body and returns the response.

func Put

func Put(baseURL string, body any, opts ...client.RequestOption) (*Response, error)

Put sends a PUT request with optional body and returns the response.

type ResponseError added in v0.1.0

type ResponseError = client.ResponseError

Error types

type Result added in v0.1.0

type Result[T any] = client.Result[T]

Type aliases for client package types - allows users to import only the main package Result wraps both parsed response data and response metadata. Use Data() to access the parsed data and Response() for metadata.

func DeleteJSON added in v0.1.0

func DeleteJSON[T any](baseURL string, opts ...client.RequestOption) (Result[T], error)

DeleteJSON sends a DELETE request and returns Result[T].

func DoJSON added in v0.1.0

func DoJSON[T any](b *RequestBuilder) (Result[T], error)

============================================================================ Generic Request Execution ============================================================================ DoJSON executes a request builder and parses JSON response into Result[T].

func DoXML added in v0.1.0

func DoXML[T any](b *RequestBuilder) (Result[T], error)

DoXML executes a request builder and parses XML response into Result[T].

func GetJSON added in v0.1.0

func GetJSON[T any](baseURL string, opts ...client.RequestOption) (Result[T], error)

============================================================================ Generic HTTP Methods - return (Result[T], error) ============================================================================ GetJSON sends a GET request and returns Result[T] with parsed JSON response.

func PatchJSON added in v0.1.0

func PatchJSON[T any](baseURL string, data any, opts ...client.RequestOption) (Result[T], error)

PatchJSON sends a PATCH request with JSON body and returns Result[T].

func PostJSON added in v0.1.0

func PostJSON[T any](baseURL string, data any, opts ...client.RequestOption) (Result[T], error)

PostJSON sends a POST request with JSON body and returns Result[T].

func PutJSON added in v0.1.0

func PutJSON[T any](baseURL string, data any, opts ...client.RequestOption) (Result[T], error)

PutJSON sends a PUT request with JSON body and returns Result[T].

type RetryError added in v0.1.0

type RetryError = client.RetryError

Error types

type RetryExecutor added in v0.1.0

type RetryExecutor = client.RetryExecutor

RetryExecutor executes requests with retry logic.

type RetryPolicy added in v0.1.0

type RetryPolicy = client.RetryPolicy

RetryPolicy defines retry behavior.

type Session added in v0.1.0

type Session = client.Session

Session extends Client with session management capabilities. It provides configuration methods like WithTimeout, WithRetry, WithMiddleware, etc.

type TimeoutError added in v0.1.0

type TimeoutError = client.TimeoutError

Error types

Directories

Path Synopsis
Package codec provides encoder/decoder interfaces and implementations.
Package codec provides encoder/decoder interfaces and implementations.
docs
examples
Package examples demonstrates context usage patterns with the requests library.
Package examples demonstrates context usage patterns with the requests library.
internal
client
Package client provides the core HTTP client interfaces and implementations.
Package client provides the core HTTP client interfaces and implementations.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL