problem

package
v1.0.1 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 5, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type HttpWriter

type HttpWriter struct {
	ProblemMapping func(error) Problem
}

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 NewBadRequestProblem(detail string) Problem

func NewForbiddenProblem

func NewForbiddenProblem(detail string) Problem

func NewInternalServerProblem

func NewInternalServerProblem(detail string) Problem

func NewNotFoundProblem

func NewNotFoundProblem(detail string) Problem

func NewUnauthorizedProblem

func NewUnauthorizedProblem(detail string) Problem

func NewValidateProblem

func NewValidateProblem(detail string) Problem

func NewValidateProblemWithErrors

func NewValidateProblemWithErrors(detail string, errors []string) Problem

func (Problem) IsEmpty

func (p Problem) IsEmpty() bool

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL