Documentation
¶
Overview ¶
Package problem is the RFC 9457 problem details the --web API answers a failure with: the status, title and type each code fixes, the default answer a strict handler returns with one, and one written by the hand-written middleware that answers before a strict handler runs.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Answer ¶
func Answer[Response ~struct {
Body api.Problem
Headers api.ProblemResponseHeaders
StatusCode int
}](prob api.Problem) Response
Answer is an operation's default answer with prob: the problem, at its own status, and a rate limit's wait as the Retry-After header. Every operation's default answer has this one shape, under its own type.
func New ¶
func New(code api.ProblemCode, detail string) api.Problem
New builds an RFC 9457 problem details object for a code, deriving its type, title and status. The detail is safe to show and never carries a secret.
func Write ¶
func Write(w http.ResponseWriter, code api.ProblemCode, detail string)
Write writes a problem details object as application/problem+json, for the hand-written middleware that answers before a strict handler runs.
func WriteRequestError ¶
func WriteRequestError(w http.ResponseWriter, _ *http.Request, _ error)
WriteRequestError answers a request the generated binder or the strict decoder could not read — a bad query parameter or a malformed body. The detail stays off the wire; that a field was wrong, not which internal parser said so, is what the caller can act on.
Types ¶
This section is empty.