response

package
v0.0.0-...-97189e1 Latest Latest
Warning

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

Go to latest
Published: Jan 1, 2023 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
var (
	InvalidJSONPayload = NewError("Invalid json payload", http.StatusBadRequest, 20)
)

Functions

func DefaultHealthCheck

func DefaultHealthCheck() map[string]any

func DefaultOkResponse

func DefaultOkResponse() map[string]any

func HealthCheck

func HealthCheck(w http.ResponseWriter, r *http.Request)

func Json

func Json(w io.Writer, v any) error

Json serializes payload to json and writes it to specified writer

func NewInvalidJSONPayloadErr

func NewInvalidJSONPayloadErr(err error) error

func WriteErrorJSONResponse

func WriteErrorJSONResponse(w http.ResponseWriter, message any, codes ...int)

func WriteJSONResponse

func WriteJSONResponse(w http.ResponseWriter, v any)

func Yaml

func Yaml(w io.Writer, v any) error

Yaml serializes payload to yaml and writes it to specified writer

Types

type ApiError

type ApiError struct {
	HttpCode     int   `json:"http_code"`
	InternalCode int   `json:"internal_code"`
	Timestamp    int64 `json:"timestamp"`
	Message      any   `json:"message"`
}

func NewError

func NewError(message any, codes ...int) *ApiError

func (*ApiError) Error

func (e *ApiError) Error() string

Jump to

Keyboard shortcuts

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