dexnet

package
v1.0.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2024 License: BlueOak-1.0.0 Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Do

func Do(req *http.Request, thing interface{}, opts ...*RequestOption) error

Do does the request and JSON-marshals the result into thing, if non-nil.

func Get

func Get(ctx context.Context, uri string, thing interface{}, opts ...*RequestOption) error

Post peforms an HTTP GET request. If thing is non-nil, the response will be JSON-unmarshaled into thing.

func Post

func Post(ctx context.Context, uri string, thing interface{}, body []byte, opts ...*RequestOption) error

Post peforms an HTTP POST request. If thing is non-nil, the response will be JSON-unmarshaled into thing.

Types

type RequestOption

type RequestOption struct {
	// contains filtered or unexported fields
}

RequestOption are optional arguemnts to Get, Post, or Do.

func WithRequestHeader

func WithRequestHeader(k, v string) *RequestOption

WithRequestHeader adds a header entry to the request.

func WithSizeLimit

func WithSizeLimit(limit int64) *RequestOption

WithSizeLimit sets a size limit for a response. See defaultResponseSizeLimit for the default.

func WithStatusFunc

func WithStatusFunc(f func(int)) *RequestOption

WithStatusFunc calls a function with the status code after the request is performed.

Jump to

Keyboard shortcuts

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