Versions in this module Expand all Collapse all v2 v2.0.1 Feb 2, 2026 Changes in this version + const DefaultTypeBase + const TypeBadRequest + const TypeConflict + const TypeForbidden + const TypeInternal + const TypeNotFound + const TypePayloadTooLarge + const TypeRateLimited + const TypeServiceUnavailable + const TypeUnauthorized + const TypeValidation + const ValidationErrorsKey + var ErrForbidden = errors.New("forbidden") + var ErrHeaderBytesExceeded = errors.New("request headers exceed max bytes") + var ErrHeaderCountExceeded = errors.New("request headers exceed max count") + var ErrTooManyRequests = errors.New("rate limit exceeded") + var ErrUnauthorized = errors.New("unauthorized") + var HeaderLimitsBalanced = HeaderLimits + var HeaderLimitsRelaxed = HeaderLimits + var HeaderLimitsStrict = HeaderLimits + func DefaultTypeForStatus(status int) string + func DefaultTypeURI(slug string) string + func HeaderBytes(h http.Header) int + func HeaderCount(h http.Header) int + func TypeURI(base, slug string) string + func WriteError(w http.ResponseWriter, err error) + func WriteErrorStrict(w http.ResponseWriter, err error) + func WriteErrorWithOptions(w http.ResponseWriter, err error, opts ErrorOptions) + func WriteJSON(w http.ResponseWriter, status int, v any) + func WriteProblem(w http.ResponseWriter, status int, p Problem) + func WriteProblemWithFieldErrors(w http.ResponseWriter, status int, p Problem, errs fielderrors.FieldErrors) + func WriteSimpleProblem(w http.ResponseWriter, status int, title, detail string) + type ErrorMode int + const ErrorModeDefault + const ErrorModeStrict + type ErrorOptions struct + Mode ErrorMode + TypeRegistry *TypeRegistry + type HTTPError struct + Detail string + Err error + Status int + Title string + Type string + func NewHTTPError(status int, detail string) *HTTPError + func (e *HTTPError) Error() string + func (e *HTTPError) Unwrap() error + type HeaderLimits struct + MaxBytes int + MaxCount int + func (l HeaderLimits) ApplyServer(s *http.Server) + func (l HeaderLimits) Check(r *http.Request) error + type Problem struct + Detail string + Ext map[string]any + Instance string + Status int + Title string + Type string + func ProblemFromError(err error) (Problem, int) + func ProblemFromErrorStrict(err error) (Problem, int) + func ProblemFromErrorWithOptions(err error, opts ErrorOptions) (Problem, int) + func WithFieldErrors(p Problem, errs fielderrors.FieldErrors) Problem + func WithValidationErrors(p Problem, errs fielderrors.FieldErrors) Problem + func (p *Problem) With(key string, value any) *Problem + type TypeRegistry struct + func DefaultTypeRegistry() *TypeRegistry + func NewTypeRegistry(base string, slugs ...string) *TypeRegistry + func (r *TypeRegistry) Register(slug string) string + func (r *TypeRegistry) Types() map[string]string + func (r *TypeRegistry) URI(slug string) string + type ValidationErrors struct + Fields fielderrors.FieldErrors Other modules containing this package github.com/aatuh/api-toolkit