Documentation
¶
Index ¶
- type HttpWriter
- type Problem
- func NewBadRequestProblem(detail string) Problem
- func NewForbiddenProblem(detail string) Problem
- func NewInternalServerProblem(detail string) Problem
- func NewNotFoundProblem(detail string) Problem
- func NewUnauthorizedProblem(detail string) Problem
- func NewValidateProblem(detail string) Problem
- func NewValidateProblemWithErrors(detail string, errors []string) Problem
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type HttpWriter ¶
func New ¶
func New() *HttpWriter
func NewWithMapping ¶
func NewWithMapping(ProblemMapping func(error) Problem) *HttpWriter
func (*HttpWriter) WriteError ¶
func (h *HttpWriter) WriteError(ctx context.Context, w http.ResponseWriter, err error, logger *zap.Logger)
func (*HttpWriter) WriteErrorWithRequest ¶
func (h *HttpWriter) WriteErrorWithRequest(ctx context.Context, r *http.Request, w http.ResponseWriter, err error, logger *zap.Logger)
type Problem ¶
type Problem struct {
Title string `json:"title"`
Status int `json:"status"`
// Type indicates the URI that identifies the problem type.
// In production, this would point to the project's documentation.
// For demonstration purposes, we use an MDN URI here.
Type string `json:"type"`
Detail string `json:"detail"`
Instance string `json:"instance,omitempty"`
Errors []string `json:"errors,omitempty"`
}
Problem represents a problem detail as defined in RFC 9457
func NewBadRequestProblem ¶
func NewForbiddenProblem ¶
func NewNotFoundProblem ¶
func NewUnauthorizedProblem ¶
func NewValidateProblem ¶
Click to show internal directories.
Click to hide internal directories.