Documentation ¶
Overview ¶
package client provides HTTP request handling functionality with various middleware options.
Index ¶
- type Client
- type MarshalFunc
- type Option
- type Query
- type Request
- func (rb *Request) Body(body []byte) *Request
- func (rb *Request) Build(ctx context.Context) (*http.Request, error)
- func (rb *Request) Do(ctx context.Context) (*http.Response, error)
- func (rb *Request) Header(key, value string) *Request
- func (rb *Request) MarshalBody(body interface{}) *Request
- func (rb *Request) MarshalWith(fn MarshalFunc) *Request
- func (rb *Request) Method(method string) *Request
- func (rb *Request) Query(key, value string) *Request
- func (rb *Request) Result(result interface{}) *Request
- func (rb *Request) URL(url string) *Request
- func (rb *Request) UnmarshalWith(fn UnmarshalFunc) *Request
- type UnmarshalFunc
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Client ¶
type Client struct {
// contains filtered or unexported fields
}
Client manages HTTP requests with various middleware options.
func (*Client) NewRequest ¶
NewRequest creates a new Request with default options.
type MarshalFunc ¶
MarshalFunc is a function type that matches standard marshal functions.
type Option ¶
type Option func(*Client)
Option is a function type that modifies the Client configuration.
func WithLogger ¶
WithLogger sets the logger for the Client and its middleware.
func WithMarshalFunc ¶
func WithMarshalFunc(fn MarshalFunc) Option
WithMarshalFunc sets the marshal function for the Client.
func WithMiddleware ¶
func WithMiddleware(middleware middleware.Middleware) Option
WithMiddleware adds or updates the middleware for the Client with a specified priority.
func WithTimeout ¶
WithTimeout sets the timeout for the Client.
func WithUnmarshalFunc ¶
func WithUnmarshalFunc(fn UnmarshalFunc) Option
WithUnmarshalFunc sets the unmarshal function for the Client.
type Query ¶
Query maps a string key to a list of values. It is typically used for query parameters and form values. Unlike in the http.Header map, the keys in a Query map are case-sensitive.
func (Query) Add ¶
Add appends a value to the list of values associated with the key. It appends to any existing values associated with the key.
func (Query) Encode ¶
Encode converts the Query into a URL-encoded string. The resulting string is in "URL encoded" form ("bar=baz&foo=quux") with keys sorted alphabetically.
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request helps build requests using method chaining.
func (*Request) MarshalBody ¶
MarshalBody sets the body of the request after marshaling the provided struct.
func (*Request) MarshalWith ¶
func (rb *Request) MarshalWith(fn MarshalFunc) *Request
MarshalWith sets the marshal function for the request body.
func (*Request) UnmarshalWith ¶
func (rb *Request) UnmarshalWith(fn UnmarshalFunc) *Request
UnmarshalWith sets the unmarshal function for the response.
type UnmarshalFunc ¶
UnmarshalFunc is a function type that matches standard unmarshal functions.