internal

package
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Dec 28, 2017 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var ErrUnknownFormat = errors.New("unknown JSON data format")

Functions

func ExchangeJSON

func ExchangeJSON(ctx context.Context, client *http.Client, endpoint string, data interface{}) (interface{}, error)

ExchangeJSON POSTs JSON to an URL and parses the response JSON into a map hierarchy. If a non-200 response is returned, the returned url.Error wraps a FailedRequestError.

func FetchJSON

func FetchJSON(ctx context.Context, client *http.Client, endpoint string) (interface{}, error)

FetchJSON GETs JSON from an URL and parses it into a map hierarchy. If a non-200 response is returned, the returned url.Error wraps a FailedRequestError.

Types

type FailedRequestError added in v1.1.0

type FailedRequestError struct {
	StatusCode   int
	ErrorCode    string
	ErrorMessage string
}

FailedRequestError represents a non-200 response from the Mojang servers, incl. potential JSON error types and messages.

func UnwrapFailedRequestError added in v1.1.0

func UnwrapFailedRequestError(uerr error) (err *FailedRequestError, ok bool)

func (*FailedRequestError) Error added in v1.1.0

func (err *FailedRequestError) Error() string

Jump to

Keyboard shortcuts

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