Documentation ¶
Index ¶
- Constants
- func ApplicationNotFoundError(message string, underlyingError error) error
- func ByteArrayResponse(w http.ResponseWriter, r *http.Request, contentType string, result []byte)
- func ErrorResponse(w http.ResponseWriter, r *http.Request, apiError error)
- func ErrorResponseForServer(w http.ResponseWriter, r *http.Request, apiError error)
- func GetBearerTokenFromHeader(r *http.Request) (string, error)
- func GetImpersonationFromHeader(r *http.Request) (models.Impersonation, error)
- func GetTokenFromQuery(request *http.Request) string
- func JSONResponse(w http.ResponseWriter, r *http.Request, result interface{})
- func NegotiateContentType(r *http.Request, orderedPref []string) string
- func NotFoundError(message string) error
- func ReaderFileResponse(w http.ResponseWriter, reader io.Reader, fileName, contentType string)
- func ReaderResponse(w http.ResponseWriter, reader io.Reader, contentType string)
- func StringResponse(w http.ResponseWriter, r *http.Request, result string)
- func TypeMissingError(message string, underlyingError error) error
- func UnexpectedError(message string, underlyingError error) error
- func ValidationError(kind, message string) error
- type AcceptSpec
- type Error
- type Type
Constants ¶
const ( // Server The operation looked fine on paper, but something went wrong Server Type = "server" // Missing The thing you mentioned, whatever it is, just doesn't exist Missing = "missing" // User The operation was well-formed, but you asked for something that // can't happen at present (e.g., because you've not supplied some // config yet) User = "user" )
Variables ¶
This section is empty.
Functions ¶
func ApplicationNotFoundError ¶
ApplicationNotFoundError indication that application was not found. Can also mean a user does not have access to the application.
func ByteArrayResponse ¶ added in v1.1.2
ByteArrayResponse Used for response data. I.e. image
func ErrorResponse ¶
func ErrorResponse(w http.ResponseWriter, r *http.Request, apiError error)
ErrorResponse Marshals error for user requester
func ErrorResponseForServer ¶ added in v1.1.2
func ErrorResponseForServer(w http.ResponseWriter, r *http.Request, apiError error)
ErrorResponseForServer Marshals error for server requester
func GetBearerTokenFromHeader ¶
GetBearerTokenFromHeader gets bearer token from request header
func GetImpersonationFromHeader ¶
func GetImpersonationFromHeader(r *http.Request) (models.Impersonation, error)
GetImpersonationFromHeader Gets Impersonation from request header
func GetTokenFromQuery ¶
GetTokenFromQuery Gets token from query of the request
func JSONResponse ¶
func JSONResponse(w http.ResponseWriter, r *http.Request, result interface{})
JSONResponse Marshals response with header
func NegotiateContentType ¶
NegotiateContentType picks a content type based on the Accept header from a request, and a supplied list of available content types in order of preference. If the Accept header mentions more than one available content type, the one with the highest quality (`q`) parameter is chosen; if there are a number of those, the one that appears first in the available types is chosen.
func NotFoundError ¶ added in v1.1.2
NotFoundError No found error
func ReaderFileResponse ¶
func ReaderFileResponse(w http.ResponseWriter, reader io.Reader, fileName, contentType string)
ReaderFileResponse writes the content from the reader to the response, and sets Content-Disposition=attachment; filename=<filename arg>
func ReaderResponse ¶ added in v1.1.11
func ReaderResponse(w http.ResponseWriter, reader io.Reader, contentType string)
ReaderResponse writes the content from the reader to the response,
func StringResponse ¶
func StringResponse(w http.ResponseWriter, r *http.Request, result string)
StringResponse Used for textual response data. I.e. log data
func TypeMissingError ¶ added in v1.1.2
TypeMissingError indication of underlying type missing
func UnexpectedError ¶
UnexpectedError any unexpected error
func ValidationError ¶ added in v1.1.2
ValidationError Used for indication of validation errors
Types ¶
type AcceptSpec ¶
func GetAccepts ¶
func GetAccepts(header netHeader.Header) ([]AcceptSpec, error)
type Error ¶
type Error struct { Type Type // a message that can be printed out for the user Message string `json:"message"` // the underlying error that can be e.g., logged for developers to look at Err error }
Error Representation of errors in the API. These are divided into a small number of categories, essentially distinguished by whose fault the error is; i.e., is this error:
- a transient problem with the service, so worth trying again?
- not going to work until the user takes some other action, e.g., updating config?
func CoverAllError ¶
CoverAllError Cover all other errors for requester type Type
func (*Error) MarshalJSON ¶
MarshalJSON Writes error as json
func (*Error) UnmarshalJSON ¶
UnmarshalJSON Parses json