Documentation
¶
Index ¶
- type Problem
- func BadRequest(err error) *Problem
- func New(statusCode int, problemType, title, detail, instance string, ...) *Problem
- func NotCurrent() *Problem
- func NotFound() *Problem
- func NotPermitted(username string) *Problem
- func RuleViolated(rule string) *Problem
- func Status(statusCode int) *Problem
- func Unexpected(err error) *Problem
- func Validation(params map[string]string) *Problem
- type ProblemConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Problem ¶
type Problem struct {
// Type is a URI reference [RFC3986] that identifies the
// problem type. This specification encourages that, when
// dereferenced, it provide human-readable documentation for the
// problem type (e.g., using HTML [W3C.REC-html5-20141028]). When
// this member is not present, its value is assumed to be
// "about:blank".
Type string `json:"type"`
// Title is a short, human-readable summary of the problem
// type. It SHOULD NOT change from occurrence to occurrence of the
// problem, except for purposes of localization (e.g., using
// proactive content negotiation; see [RFC7231], Section 3.4).
Title string `json:"title"`
// Status is the HTTP status code ([RFC7231], Section 6)
// generated by the origin server for this occurrence of the problem.
Status int `json:"status,omitempty"`
// Detail is a human-readable explanation specific to this
// occurrence of the problem.
// If present, it ought to focus on helping the client
// correct the problem, rather than giving debugging information.
Detail string `json:"detail,omitempty"`
// Instance is a URI reference that identifies the specific
// occurrence of the problem. It may or may not yield further
// information if dereferenced.
Instance string `json:"instance,omitempty"`
// Params are request input field level errors. They communicate
// back to client hints as to the exact problem.
Params map[string]string `json:"params,omitempty"`
}
Problem is the struct definition of a problem details object
func BadRequest ¶
BadRequest will create a new problem for reqeust marshalling errors.
func New ¶
func New(statusCode int, problemType, title, detail, instance string, params map[string]string) *Problem
New creates a new Problem with given info.
func NotCurrent ¶
func NotCurrent() *Problem
NotCurrent will create a new problem for optimistic concurrency errors.
func NotFound ¶
func NotFound() *Problem
NotFound will create a new problem for when the record is not found.
func NotPermitted ¶
NotPermitted will create a new problem for when the user is forbidden access.
func RuleViolated ¶
RuleViolated will create a new problem for when a business rule is violated.
func Unexpected ¶
Unexpected will create a new problem for unexpected errors.
func Validation ¶
Validation will create a new problem for when request has field validation errors.