Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func JSONError ¶
func JSONError(w http.ResponseWriter, err interface{}, code int)
JSONError is https://pkg.go.dev/net/http#Error, but for JSON.
Types ¶
type ProblemDetailer ¶
ProblemDetailer should be implemented by any error that has should be encoded as a specific RFC 7807 problem detail.
type StatusProblem ¶
type StatusProblem struct {
Status int `json:"-"`
Detail string `json:"detail,omitempty"`
Err error
}
StatusProblem is basically an error with an HTTP status code.
func NewInternalProblem ¶
func NewInternalProblem(detail string, err error) *StatusProblem
NewInternalProblem returns a StatusProblem with code 500.
func NewStatusProblem ¶
func NewStatusProblem(code int, detail string, err error) *StatusProblem
NewStatusProblem is a helper to create a StatusProblem.
func (*StatusProblem) Code ¶
func (p *StatusProblem) Code() int
Code returns the HTTP status code of p.
func (*StatusProblem) Error ¶
func (p *StatusProblem) Error() string
func (*StatusProblem) ProblemDetail ¶
func (p *StatusProblem) ProblemDetail() any
ProblemDetail turns p into a RFC 7807 problem detail.
func (*StatusProblem) String ¶
func (p *StatusProblem) String() string
Click to show internal directories.
Click to hide internal directories.