Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type Controller ¶
type Controller struct{}
func NewController ¶
func NewController() Controller
func (Controller) WriteError ¶
func (c Controller) WriteError(ctx context.Context, w http.ResponseWriter, err error)
func (Controller) WriteJSON ¶
func (c Controller) WriteJSON(ctx context.Context, w http.ResponseWriter, httpStatus int, data any)
func (Controller) WriteText ¶
func (c Controller) WriteText(ctx context.Context, w http.ResponseWriter, httpStatus int, message string)
type ErrorResponse ¶
type ErrorResponse struct {
// Message is a human-readable description of what went wrong. Intended for
// logging and debugging, not for programmatic branching (use errorCode for that).
Message string `json:"message"`
// ErrorCode is a stable numeric application error code identifying the error type.
// Use it for programmatic handling; it does not change across locales or message wording.
ErrorCode int `json:"errorCode"`
// Args are optional values interpolated into the message template (e.g. field names
// or limits). Their order matches the placeholders in the message.
Args []jsontext.Value `json:"args,omitempty"`
}
ErrorResponse is the body returned for every non-2xx response.
Click to show internal directories.
Click to hide internal directories.