Documentation ¶
Index ¶
- Variables
- func UnmarshalRequestBody(r *http.Request, j interface{}) error
- func UnmarshalRequestBytes(r *http.Request, b []byte, j interface{}) error
- func UnmarshalWithKind(kind OutputKind, b []byte, j interface{}) error
- func WriteAuto(output interface{}, err error, errCode ErrorCodes, r *http.Request, ...) error
- func WriteErr(err error, code ErrorCodes, r *http.Request, rw http.ResponseWriter) error
- func WriteError(msg string, code ErrorCodes, r *http.Request, rw http.ResponseWriter) error
- func WriteOutput(isError bool, statusCode int, output interface{}, r *http.Request, ...) error
- type ApiError
- type Context
- type Error
- type ErrorCodes
- type OutputKind
- type ReqContext
- func (rc ReqContext) Unmarshal(body []byte, j interface{}) error
- func (rc ReqContext) ValidateBytes(body []byte, j interface{}) error
- func (rc ReqContext) ValidateStruct(input interface{}) error
- func (rc ReqContext) WriteAuto(output interface{}, error error, errCode ErrorCodes)
- func (rc ReqContext) WriteErr(err error, errCode ErrorCodes)
- func (rc ReqContext) WriteError(msg string, errCode ErrorCodes)
- func (rc ReqContext) WriteOutput(output interface{}, statusCode int)
Constants ¶
This section is empty.
Variables ¶
View Source
var ( ErrIDNonValid = NewError("Id was not valid", CodeErrIDNonValid) ErrIDTooLong = NewError("Id was too long", CodeErrIDTooLong) ErrIDEmpty = NewError("Id was empty", CodeErrIDEmpty) )
Functions ¶
func UnmarshalRequestBody ¶
func UnmarshalRequestBytes ¶
func UnmarshalWithKind ¶
func UnmarshalWithKind(kind OutputKind, b []byte, j interface{}) error
func WriteAuto ¶
func WriteAuto(output interface{}, err error, errCode ErrorCodes, r *http.Request, rw http.ResponseWriter) error
func WriteErr ¶
func WriteErr(err error, code ErrorCodes, r *http.Request, rw http.ResponseWriter) error
func WriteError ¶
func WriteError(msg string, code ErrorCodes, r *http.Request, rw http.ResponseWriter) error
func WriteOutput ¶
Types ¶
type Error ¶
type Error struct { Code ErrorCodes Message string }
func NewError ¶
func NewError(msg string, code ErrorCodes) Error
type ErrorCodes ¶
type ErrorCodes string
const ( CodeErrEndpoint ErrorCodes = "Error: Regarding type Endpoint" CodeErrRequest ErrorCodes = "Error: Regarding type Request" CodeErrMethodNotAllowed ErrorCodes = "Error: HTTP-Method is not allowed" CodeErrNoRoute ErrorCodes = "Error: No route matched for this http-path" CodeErrReadBody ErrorCodes = "Error: Failed to read body" CodeErrMarhal ErrorCodes = "Error: Failed to marshal" CodeErrUnmarshal ErrorCodes = "Error: Failed to unmarshal" CodeErrJmesPath ErrorCodes = "Error: JmesPath" CodeErrJmesPathMarshal ErrorCodes = "Error: JmesPathMarshal" CodeErrInputValidation ErrorCodes = "Error: General input validation" CodeErrIDNonValid ErrorCodes = "Error: ID not valid" CodeErrIDTooLong ErrorCodes = "Error: ID is too long" CodeErrIDEmpty ErrorCodes = "Error: ID was Empty" CodeErrDBUpdateSchedule ErrorCodes = "Error: Database Update Schedule" CodeErrDBUpdateEndpoint ErrorCodes = "Error: Database Update Endpoint" CodeErrDBUpdateRequest ErrorCodes = "Error: Database Update Request" CodeErrDBDeleteEndpoint ErrorCodes = "Error: Database Delete Endpoint" CodeErrDBDeleteRequest ErrorCodes = "Error: Database Delete Request" CodeErrDBDeleteSchedule ErrorCodes = "Error: Database Delete Schedule" CodeErrDBCreateEndpoint ErrorCodes = "Error: Database Create Endpoint" CodeErrSchedule ErrorCodes = "Error: Database Create Schedule" CodeErrDBCreateRequest ErrorCodes = "Error: Database Create Request" CodeErrDBCreateSchedule ErrorCodes = "Error: Database Create Schedule" )
type OutputKind ¶
type OutputKind = int
const ( OutputJson OutputKind = iota + 1 OutputYaml OutputToml )
func WantedOutputFormat ¶
func WantedOutputFormat(r *http.Request) OutputKind
attempts to guess at what kind of output the user most likely wants
type ReqContext ¶
type ReqContext struct { Context *Context Req *http.Request L logger.AppLogger Rw http.ResponseWriter ContentKind OutputKind Accept OutputKind }
func NewReqContext ¶
func NewReqContext(context *Context, req *http.Request, rw http.ResponseWriter) ReqContext
func (ReqContext) Unmarshal ¶
func (rc ReqContext) Unmarshal(body []byte, j interface{}) error
func (ReqContext) ValidateBytes ¶
func (rc ReqContext) ValidateBytes(body []byte, j interface{}) error
Will perform validation and write errors to responsewriter if validation failed. If err is non-nill, the caller should simply return
func (ReqContext) ValidateStruct ¶
func (rc ReqContext) ValidateStruct(input interface{}) error
func (ReqContext) WriteAuto ¶
func (rc ReqContext) WriteAuto(output interface{}, error error, errCode ErrorCodes)
func (ReqContext) WriteErr ¶
func (rc ReqContext) WriteErr(err error, errCode ErrorCodes)
func (ReqContext) WriteError ¶
func (rc ReqContext) WriteError(msg string, errCode ErrorCodes)
func (ReqContext) WriteOutput ¶
func (rc ReqContext) WriteOutput(output interface{}, statusCode int)
Click to show internal directories.
Click to hide internal directories.