render

package
v0.0.0-...-495eea3 Latest Latest
Warning

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

Go to latest
Published: Feb 21, 2023 License: MIT Imports: 6 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func DecodeJSON

func DecodeJSON(r io.Reader, v interface{}) error

func Err

func Err(w http.ResponseWriter, status int, opts ...ErrOption)

func ErrInternal

func ErrInternal(w http.ResponseWriter, err error)

func ErrInternalWithRequestID

func ErrInternalWithRequestID(w http.ResponseWriter, id string, err error)

func ErrInvalidRequest

func ErrInvalidRequest(w http.ResponseWriter, err error)

func ErrInvalidRequestWithRequestID

func ErrInvalidRequestWithRequestID(w http.ResponseWriter, id string, err error)

func ErrNotFound

func ErrNotFound(w http.ResponseWriter)

func ErrResourceNotFound

func ErrResourceNotFound(w http.ResponseWriter, resource string)

func ErrUnauthorized

func ErrUnauthorized(w http.ResponseWriter)

func ErrUnauthorizedWithRequestID

func ErrUnauthorizedWithRequestID(w http.ResponseWriter, id string)

func JSON

func JSON(w http.ResponseWriter, status int, v interface{})

JSON writes an http response using the value passed in v as JSON. If it cannot convert the value to JSON, it returns an error

func NoContent

func NoContent(w http.ResponseWriter)

Types

type ErrOption

type ErrOption func(er *ErrResponse)

func WithError

func WithError(err error) ErrOption

func WithErrorID

func WithErrorID(id string) ErrOption

func WithStatus

func WithStatus(status string) ErrOption

type ErrResponse

type ErrResponse struct {
	Status    string `json:"status,omitempty"`
	Error     string `json:"error,omitempty"`
	RequestID string `json:"request_id,omitempty"`
}

Jump to

Keyboard shortcuts

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