responses

package
v0.0.0-...-dd0ccd7 Latest Latest
Warning

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

Go to latest
Published: Mar 28, 2022 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func EncodeJSONResponse

func EncodeJSONResponse(_ context.Context, w http.ResponseWriter, response interface{}) error

func ErrorEncodeJSONResponse

func ErrorEncodeJSONResponse(f func(errorVal errors.Error) (code int)) func(_ context.Context, err error, w http.ResponseWriter)

func HTTPStatusFromCode

func HTTPStatusFromCode(code codes.Code) int

HTTPStatusFromCode converts a gRPC error code into the corresponding HTTP response status. See: https://github.com/googleapis/googleapis/blob/master/google/rpc/code.proto

func JSONErrorDecoder

func JSONErrorDecoder(r *http.Response) error

Types

type BinaryResponser

type BinaryResponser interface {
	GetBinary() (res []byte)
}

type DataRes

type DataRes struct {
	APIVersion string      `json:"apiVersion"`
	Data       interface{} `json:"data"`
}

type ErrorRes

type ErrorRes struct {
	Error ErrorResItem `json:"error"`
}

type ErrorResItem

type ErrorResItem struct {
	Code    int             `json:"code"`
	Message string          `json:"message"`
	Errors  []errors.Errors `json:"errors"`
}

type ErrorWrapper

type ErrorWrapper struct {
	Error string `json:"error"`
}

type Paging

type Paging struct {
	Total  uint64 `json:"total"`
	Offset uint64 `json:"offset"`
	Limit  uint64 `json:"limit"`
}

type Responser

type Responser interface {
	Response() (res interface{})
}

Jump to

Keyboard shortcuts

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