Source File
types.go
Belonging Package
github.com/goforj/httpx
package httpximport// Result contains the decoded response body and response metadata.type Result[ any] struct {BodyResponse *req.ResponseErr error}// Option applies configuration to a client or request.type Option interface {applyClient(*Client)applyRequest(*req.Request)}type option struct {clientFn func(*Client)requestFn func(*req.Request)}func ( option) ( *Client) {if .clientFn == nil {return}.clientFn()}func ( option) ( *req.Request) {if .requestFn == nil {return}.requestFn()}func clientOnly( func(*Client)) Option {return option{clientFn: }}func requestOnly( func(*req.Request)) Option {return option{requestFn: }}func bothOption( func(*Client), func(*req.Request)) Option {return option{clientFn: ,requestFn: ,}}// OptionBuilder chains request and client options.// @group Options//// Example: chain options//// opt := httpx.Header("X-Trace", "1").Query("q", "go")// _ = opttype OptionBuilder struct {ops []Option}func ( OptionBuilder) ( Option) OptionBuilder {.ops = append(.ops, )return}func ( OptionBuilder) ( *Client) {for , := range .ops {if == nil {continue}.applyClient()}}func ( OptionBuilder) ( *req.Request) {for , := range .ops {if == nil {continue}.applyRequest()}}// ErrorMapperFunc customizes error creation for non-2xx responses.type ErrorMapperFunc func(*req.Response) error
![]() |
The pages are generated with Golds v0.8.7. (GOOS=linux GOARCH=amd64) Golds is a Go 101 project developed by Tapir Liu. PR and bug reports are welcome and can be submitted to the issue list. Please follow @zigo_101 (reachable from the left QR code) to get the latest news of Golds. |