Documentation
¶
Index ¶
- func DecodeJSON(r *http.Request, v interface{}) ([]byte, error)
- func ErrorHandler(h ErrorReturningHandler) http.HandlerFunc
- func RespondJSON(w http.ResponseWriter, r *http.Request, status int, payload interface{}) error
- func ValidateContentType(r *http.Request, contentType string) bool
- type ApiError
- type ErrorResponse
- type ErrorReturningHandler
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func DecodeJSON ¶
DecodeJSON decodes JSON request body into the provided struct
func ErrorHandler ¶ added in v1.2.0
func ErrorHandler(h ErrorReturningHandler) http.HandlerFunc
func RespondJSON ¶
RespondJSON sends a JSON response with proper headers
Types ¶
type ApiError ¶ added in v1.2.0
type ApiError struct {
// contains filtered or unexported fields
}
func BadRequestErr ¶ added in v1.2.0
func InternalServerErr ¶ added in v1.2.0
func NewApiError ¶ added in v1.2.0
func UnauthorizedErr ¶ added in v1.2.0
type ErrorResponse ¶ added in v1.2.0
type ErrorReturningHandler ¶ added in v1.2.0
type ErrorReturningHandler func(w http.ResponseWriter, r *http.Request) *ApiError
Click to show internal directories.
Click to hide internal directories.