Documentation
¶
Index ¶
- Variables
- func EnsureLogger() *slog.Logger
- func Logger() *slog.Logger
- func RegisterExtension(ext Extension)
- func SetLogger(l *slog.Logger)
- func SprintfMany(prefix, sep string, params ...any) (s string)
- type ContentGetter
- type ErrorTypeURI
- type Extension
- type MIMEType
- type Response
- func (r *Response) AddExtension(ext Extension)
- func (r *Response) Error() string
- func (r *Response) HTTPStatusCode() int
- func (r *Response) MIMEType() MIMEType
- func (*Response) ResponsePayload()
- func (r *Response) UnmarshalJSON(data []byte) error
- func (r *Response) Write(w http.ResponseWriter) error
- type ResponseArgs
- type ResponsePayload
- type Selector
Constants ¶
This section is empty.
Variables ¶
View Source
var ResponseArchetype = reflect.TypeOf((*Response)(nil))
Functions ¶
func EnsureLogger ¶
func RegisterExtension ¶
func RegisterExtension(ext Extension)
func SprintfMany ¶
SprintfMany allows printing many name-value pairs starting with a prefix, e.g
func (r *Response) Error() string {
return SprintfMany(r.Title, "\n",
"title=%s", r.Title,
"error_type=%s", r.Type,
"error_detail=%s", r.Detail,
"http_status=%d", r.Status,
"instance=%s", r.Instance,
"parameter=%s", r.Parameter,
"expected_type=%s", r.ExpectedType,
"received_value=%s", r.ReceivedValue,
"error_location=%s", r.Location,
"constraint=%v", r.Constraint,
"suggestion=%s", r.Suggestion,
"validation_errors=%v", r.ValidationErrors,
"received_value=%s", r.ReceivedValue,
)
}
Types ¶
type ContentGetter ¶
type ContentGetter interface {
Content() any
}
type ErrorTypeURI ¶
type ErrorTypeURI string
const ( ErrorTypeRootURI ErrorTypeURI = "https://schema.xmlui.org/errors" TestServerAPIPath ErrorTypeURI = "/test-server/api" )
Error type URLs (RFC 9457 requires absolute URIs)
const ( InvalidParameterErrorType ErrorTypeURI = uri + path + "/validation/invalid-parameter-type" ConstraintViolationErrorType ErrorTypeURI = uri + path + "/validation/constraint-violation" MissingParametersErrorType ErrorTypeURI = uri + path + "/validation/missing-required-parameters" CurrentlyUnhandledErrorType ErrorTypeURI = uri + path + "/validation/currently-unhandled" InvalidBodyFormatErrorType ErrorTypeURI = uri + path + "/validation/invalid-body-format" InvalidURLFormatErrorType ErrorTypeURI = uri + path + "/validation/invalid-url-format" InvalidURLParameterErrorType ErrorTypeURI = uri + path + "/validation/invalid-url-parameter" InvalidDBQueryErrorType ErrorTypeURI = uri + path + "/validation/invalid-database-query" InternalServerErrorType ErrorTypeURI = uri + path + "/server/internal" EndpointNotMatchedErrorType ErrorTypeURI = uri + path + "/routing/endpoint-not-matched" NoResultsErrorType ErrorTypeURI = uri + path + "/database/no-results" CardinalityMismatchErrorType ErrorTypeURI = uri + path + "/routing/cardinality-mismatch" MethodNotAllowedErrorType ErrorTypeURI = uri + path + "/routing/method-not-allowed" QueryFailedErrorType ErrorTypeURI = uri + path + "/database/query-failed" )
type Response ¶
type Response struct {
Type ErrorTypeURI `json:"type"`
Title string `json:"title"`
Status int `json:"status"`
Detail string `json:"detail,omitempty"`
Instance string `json:"instance,omitempty"`
Extensions []Extension `json:"extensions,omitempty"`
}
func NewResponse ¶
func NewResponse(args ResponseArgs) *Response
func (*Response) AddExtension ¶
func (*Response) HTTPStatusCode ¶
func (*Response) ResponsePayload ¶
func (*Response) ResponsePayload()
func (*Response) UnmarshalJSON ¶
type ResponseArgs ¶
type ResponseArgs struct {
Type ErrorTypeURI `json:"type"`
Title string `json:"title"`
Status int `json:"status"`
Detail string `json:"detail"`
Instance string `json:"instance"`
Extensions []Extension `json:"extensions"`
}
func (*ResponseArgs) AddExtension ¶
func (r *ResponseArgs) AddExtension(ext Extension)
type ResponsePayload ¶
Click to show internal directories.
Click to hide internal directories.