Documentation
¶
Index ¶
Constants ¶
View Source
const ContentType = "application/problem+json"
ContentType is the standard RFC 9457 media type for Problem Details JSON payloads.
View Source
const DefaultTypePrefix = "urn:hclapi:error:"
DefaultTypePrefix is the standard URN namespace prefix for built-in problem types.
Variables ¶
This section is empty.
Functions ¶
func DefaultHandler ¶
func DefaultHandler(w http.ResponseWriter, r *http.Request, p Problem)
DefaultHandler serializes a Problem as an application/problem+json response.
Types ¶
type Handler ¶
type Handler func(w http.ResponseWriter, r *http.Request, p Problem)
Handler defines the contract for serializing Problem Details to an HTTP client.
type InvalidParam ¶
InvalidParam represents a single field-level schema validation failure.
type Problem ¶
type Problem struct {
Type string `json:"type,omitempty"`
Title string `json:"title"`
Status int `json:"status"`
Detail string `json:"detail,omitempty"`
Instance string `json:"instance,omitempty"`
Step string `json:"step,omitempty"`
InvalidParams []InvalidParam `json:"invalid_params,omitempty"`
Extensions map[string]any `json:"-"`
}
Problem represents an RFC 9457 compliant error object.
func New ¶
New constructs a Problem with canonical title and type URI derived from the HTTP status code.
Click to show internal directories.
Click to hide internal directories.