json

package
v0.0.0-...-b43d8b8 Latest Latest
Warning

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

Go to latest
Published: May 28, 2020 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var DefaultEncoder request.Encoder = func(v interface{}) (io.Reader, error) {
	buff, err := json.Marshal(v)
	if err != nil {
		return nil, err
	}
	return bytes.NewBuffer(buff), nil
}

DefaultEncoder marshal data and create new bytes buffer

View Source
var DefaultOptions = []request.Option{
	request.WithEncoder(DefaultEncoder),
	request.WithHeader(
		request.StringValue("Accept", "application/json"),
		request.StringValue("Content-Type", "application/json"),
	),
}

DefaultOptions default option for the json

Functions

func Get

Get create new get request with json encoder for the body

func Post

Post create new post request with json encoder for the body

func Request

func Request(ctx context.Context, opts ...request.Option) request.ClientRequest

Request create new post request with json encoder for the body

Types

This section is empty.

Jump to

Keyboard shortcuts

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