json

package
v0.0.57 Latest Latest
Warning

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

Go to latest
Published: Sep 28, 2020 License: Apache-2.0 Imports: 11 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeRequest

func DecodeRequest(r *http.Request, data interface{}) (err error)

DecodeRequest decodes http request body.

func DecodeResponse added in v0.0.25

func DecodeResponse(res *http.Response, data interface{}) (err error)

DecodeResponse decodes http response body.

func EncodeRequest added in v0.0.25

func EncodeRequest(req *http.Request,
	data interface{}, contentTypes ...string) error

EncodeRequest encodes http request.

func EncodeResponse

func EncodeResponse(w http.ResponseWriter,
	data interface{}, status int, contentTypes ...string) error

func ErrorHandler

func ErrorHandler(w http.ResponseWriter, r *http.Request,
	msg string, code int, err error) error

func Handler

func Handler(w http.ResponseWriter, r *http.Request,
	data interface{}, logic func() (interface{},
		error)) (code int, err error)

func Request added in v0.0.25

func Request(ctx context.Context, method, url string, payload, data interface{}) error

Request sends http json request.

Types

type RFC7807Error

type RFC7807Error struct {
	Type     string      `json:"type"`
	Title    string      `json:"title"`
	Detail   interface{} `json:"detail"`
	Instance string      `json:"instance"`
	Status   int         `json:"status"`
	Error    string      `json:"error"`
}

Jump to

Keyboard shortcuts

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