Documentation ¶
Overview ¶
Apache v2 license
* Copyright (C) <2019> Intel Corporation * * SPDX-License-Identifier: Apache-2.0
Apache v2 license
* Copyright (C) <2019> Intel Corporation * * SPDX-License-Identifier: Apache-2.0
Index ¶
- Constants
- func EntityTooLargeError() error
- func Error(ctx context.Context, writer http.ResponseWriter, err error)
- func InvalidIDError() error
- func InvalidInputError(err error) error
- func IsNotFoundError(err error) bool
- func NotAuthorizedError() error
- func NotFoundError() error
- func Respond(ctx context.Context, writer http.ResponseWriter, data interface{}, code int)
- func RespondError(ctx context.Context, writer http.ResponseWriter, err error, code int)
- func RespondHTML(writer http.ResponseWriter, title string, body string, code int)
- func ValidationError(msg string) error
- type CommonError
- type ContextValues
- type Handler
- type JSONError
- type Middleware
Constants ¶
const KeyValues ctxKey = 1
KeyValues is how request values or stored/retrieved.
Variables ¶
This section is empty.
Functions ¶
func EntityTooLargeError ¶
func EntityTooLargeError() error
EntityTooLargeError occurs when the input data is too large.
func Error ¶
func Error(ctx context.Context, writer http.ResponseWriter, err error)
Error handles all error responses for the API.
func InvalidIDError ¶
func InvalidIDError() error
InvalidIDError occurs when an ID is not in a valid form.
func InvalidInputError ¶
InvalidInputError occurs when external data validation fails, giving a suberror.
func IsNotFoundError ¶
IsNotFoundError returns true if an error is an instance of a NotFoundError, or a wrapped instance of a NotFoundError.
func NotAuthorizedError ¶
func NotAuthorizedError() error
NotAuthorizedError occurs when the call is not authorized.
func NotFoundError ¶
func NotFoundError() error
func Respond ¶
func Respond(ctx context.Context, writer http.ResponseWriter, data interface{}, code int)
Respond sends JSON to the client. If code is StatusNoContent, v is expected to be nil.
func RespondError ¶
RespondError sends JSON describing the error
func RespondHTML ¶
func RespondHTML(writer http.ResponseWriter, title string, body string, code int)
RespondHTML sends HTML to the client. If code is StatusNoContent, body is expected to be nil.
func ValidationError ¶
ValidationError occurs when there are internal validation errors, giving a message.
Types ¶
type CommonError ¶
type CommonError struct { Code int // contains filtered or unexported fields }
CommonError makes it easier to identify and handle common errors.
type ContextValues ¶
ContextValues used during log
type JSONError ¶
type JSONError struct { // The error message // in: body Error string `json:"error"` }
JSONError is the response for errors that occur within the API. swagger:response internalError
type Middleware ¶
A Middleware is a type that wraps a handler to remove boilerplate or other concerns not direct to any given Handler.