Documentation
¶
Index ¶
- type ProblemDetails
- func (p ProblemDetails) AddFieldError(err ProblemDetailsFieldError) ProblemDetails
- func (p ProblemDetails) AddFieldErrors(errs []ProblemDetailsFieldError) ProblemDetails
- func (p ProblemDetails) Error() string
- func (p ProblemDetails) ServeJSON(w http.ResponseWriter, _ *http.Request) error
- func (p ProblemDetails) WithCode(code int) ProblemDetails
- func (p ProblemDetails) WithDetail(detail string) ProblemDetails
- func (p ProblemDetails) WithInstance(instance string) ProblemDetails
- func (p ProblemDetails) WithLimit(limit int) ProblemDetails
- func (p ProblemDetails) WithStatus(status int) ProblemDetails
- func (p ProblemDetails) WithTitle(title string) ProblemDetails
- func (p ProblemDetails) WithType(typeContext, t string) ProblemDetails
- type ProblemDetailsFieldError
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type ProblemDetails ¶
type ProblemDetails struct {
Type string `json:"type,omitempty" example:"urn:auth-session-api/healthcheck/check"`
Title string `json:"title,omitempty" example:"Health check server failed"`
Status int `json:"status,omitempty" example:"500"`
Detail string `json:"detail,omitempty" example:"An error occurred while performing the health check"`
Instance string `json:"instance,omitempty" example:"/health"`
FieldErrors []ProblemDetailsFieldError `json:"errors,omitempty"`
Limit int `json:"limit,omitempty" example:"10"`
Code int `json:"code,omitempty" example:"1001"`
}
ProblemDetails represents an RFC 7807 problem details response
func NewProblemDetails ¶
func NewProblemDetails() ProblemDetails
NewProblemDetails creates a new ProblemDetails with default type "about:blank".
func (ProblemDetails) AddFieldError ¶
func (p ProblemDetails) AddFieldError(err ProblemDetailsFieldError) ProblemDetails
AddFieldError appends a single field error to the ProblemDetails.
func (ProblemDetails) AddFieldErrors ¶
func (p ProblemDetails) AddFieldErrors(errs []ProblemDetailsFieldError) ProblemDetails
AddFieldErrors appends multiple field errors to the ProblemDetails.
func (ProblemDetails) Error ¶
func (p ProblemDetails) Error() string
func (ProblemDetails) ServeJSON ¶
func (p ProblemDetails) ServeJSON(w http.ResponseWriter, _ *http.Request) error
ServeJSON writes the ProblemDetails as JSON to the HTTP response writer.
func (ProblemDetails) WithCode ¶
func (p ProblemDetails) WithCode(code int) ProblemDetails
WithCode sets the code field of the ProblemDetails.
func (ProblemDetails) WithDetail ¶
func (p ProblemDetails) WithDetail(detail string) ProblemDetails
WithDetail sets the detail field of the ProblemDetails.
func (ProblemDetails) WithInstance ¶
func (p ProblemDetails) WithInstance(instance string) ProblemDetails
WithInstance sets the instance field of the ProblemDetails.
func (ProblemDetails) WithLimit ¶
func (p ProblemDetails) WithLimit(limit int) ProblemDetails
WithLimit sets the limit field of the ProblemDetails.
func (ProblemDetails) WithStatus ¶
func (p ProblemDetails) WithStatus(status int) ProblemDetails
WithStatus sets the HTTP status code of the ProblemDetails.
func (ProblemDetails) WithTitle ¶
func (p ProblemDetails) WithTitle(title string) ProblemDetails
WithTitle sets the title field of the ProblemDetails.
func (ProblemDetails) WithType ¶
func (p ProblemDetails) WithType(typeContext, t string) ProblemDetails
WithType sets the type field using a formatted URN pattern.
type ProblemDetailsFieldError ¶
type ProblemDetailsFieldError struct {
Field string `json:"field" example:"username"`
Message string `json:"message" example:"validation failed for 'required' tag"`
}
ProblemDetailsFieldError represents a field validation error
func NewProblemDetailsFieldError ¶
func NewProblemDetailsFieldError(field, message string) ProblemDetailsFieldError
NewProblemDetailsFieldError creates a new ProblemDetailsFieldError with the specified field and message.
func NewProblemDetailsFromStructValidation ¶
func NewProblemDetailsFromStructValidation(ve validator.ValidationErrors) []ProblemDetailsFieldError
NewProblemDetailsFromStructValidation converts validator.ValidationErrors to ProblemDetailsFieldError slice.