Documentation ¶
Index ¶
- Variables
- func AddSignature(r *http.Request, keyID string, secret, payload []byte)
- func AddTracerToDefaultClient(tracerProvider trace.TracerProvider)
- func CreateClient(timeout time.Duration, onRedirect func(*http.Request, []*http.Request) error) *http.Client
- func DiscardBody(body io.ReadCloser) error
- func Do(req *http.Request) (*http.Response, error)
- func DoWithClient(client *http.Client, req *http.Request) (*http.Response, error)
- func ReadBodyRequest(r *http.Request) ([]byte, error)
- func ReadBodyResponse(r *http.Response) ([]byte, error)
- func ValidateSignature(r *http.Request, secret []byte) (bool, error)
- type Request
- func (r Request) BasicAuth(username, password string) Request
- func (r Request) Build(ctx context.Context, payload io.ReadCloser) (*http.Request, error)
- func (r Request) ContentForm() Request
- func (r Request) ContentJSON() Request
- func (r Request) ContentType(contentType string) Request
- func (r Request) Delete(url string) Request
- func (r Request) Form(ctx context.Context, data url.Values) (*http.Response, error)
- func (r Request) Get(url string) Request
- func (r Request) Header(name, value string) Request
- func (r Request) IsZero() bool
- func (r Request) JSON(ctx context.Context, body interface{}) (*http.Response, error)
- func (r Request) Method(method string) Request
- func (r Request) Patch(url string) Request
- func (r Request) Path(path string) Request
- func (r Request) Post(url string) Request
- func (r Request) Put(url string) Request
- func (r Request) Send(ctx context.Context, payload io.ReadCloser) (*http.Response, error)
- func (r Request) String() string
- func (r Request) URL(url string) Request
- func (r Request) WithClient(client *http.Client) Request
- func (r Request) WithSignatureAuthorization(keyID string, secret []byte) Request
Constants ¶
This section is empty.
Variables ¶
var NoRedirection = func(*http.Request, []*http.Request) error { return http.ErrUseLastResponse }
NoRedirection discard redirection
Functions ¶
func AddSignature ¶ added in v4.20.0
AddSignature add Authorization header based on content signature based on https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12
func AddTracerToDefaultClient ¶ added in v4.36.0
func AddTracerToDefaultClient(tracerProvider trace.TracerProvider)
AddTracerToDefaultClient change default client
func CreateClient ¶ added in v4.28.1
func CreateClient(timeout time.Duration, onRedirect func(*http.Request, []*http.Request) error) *http.Client
CreateClient creates http client with given timeout and redirection handling
func DiscardBody ¶ added in v4.22.3
func DiscardBody(body io.ReadCloser) error
DiscardBody of a response
func DoWithClient ¶
DoWithClient send request with given client
func ReadBodyRequest ¶
ReadBodyRequest return content of a body request (defined as a ReadCloser)
func ReadBodyResponse ¶
ReadBodyResponse return content of a body response (defined as a ReadCloser)
func ValidateSignature ¶ added in v4.20.0
ValidateSignature check Authorization header based on content based on https://datatracker.ietf.org/doc/html/draft-cavage-http-signatures-12
Types ¶
type Request ¶
type Request struct {
// contains filtered or unexported fields
}
Request describe a complete request
func (Request) ContentForm ¶
ContentForm set Content-Type header to application/x-www-form-urlencoded
func (Request) ContentJSON ¶
ContentJSON set Content-Type header to application/json
func (Request) ContentType ¶
ContentType set Content-Type header
func (Request) WithClient ¶
WithClient defines net/http client to use, instead of default one (15sec timeout and no redirect)