httpclient

package
v1.6.5 Latest Latest
Warning

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

Go to latest
Published: Dec 27, 2022 License: MIT Imports: 14 Imported by: 0

Documentation

Index

Constants

View Source
const (
	// ContentTypeJSON json format
	ContentTypeJSON = "application/json; charset=utf-8"
	// ContentTypeForm form format
	ContentTypeForm = "application/x-www-form-urlencoded; charset=utf-8"

	// DefaultTimeout max exec time for a request
	DefaultTimeout = 3 * time.Second
)

Variables

This section is empty.

Functions

func GetJSON

func GetJSON(ctx context.Context, url string, options ...Option) ([]byte, error)

GetJSON get json data by get method

func PostForm

func PostForm(ctx context.Context, url string, form url.Values, options ...Option) ([]byte, error)

PostForm send form data by post method

func PostJSON

func PostJSON(ctx context.Context, url string, data json.RawMessage, options ...Option) ([]byte, error)

PostJSON send json data by post method

Types

type Option

type Option func(c *options)

Option is a function that sets some option on the client.

func WithTimeout

func WithTimeout(duration time.Duration) Option

WithTimeout with a timeout for per request

Jump to

Keyboard shortcuts

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