Documentation
¶
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func AccessLog ¶ added in v0.21.0
func AccessLog(log *slog.Logger) echo.MiddlewareFunc
AccessLog writes the one result record for each request: the access fields, and for a failed request the error fields of its attribution. It recovers a panic into an error with the stack of the panic, and answers an error that is still unanswered through the shell's HTTP error handler, so the record carries the status that was sent.
Install it directly after telemetry.EchoServer, so the record is logged with the request's span and every middleware below it is covered.
func NewHTTPErrorHandler ¶ added in v0.21.0
func NewHTTPErrorHandler(log *slog.Logger) echo.HTTPErrorHandler
NewHTTPErrorHandler renders every error a request ends with as a Problem. It does not log the error: the access log writes the one result record for the request. An HTTP shell installs it together with AccessLog.
Types ¶
type Problem ¶ added in v0.22.0
type Problem struct {
Type string `json:"type" validate:"required"`
Status int `json:"status" validate:"required"`
Detail string `json:"detail" validate:"required"`
Code string `json:"code" validate:"required"`
Args map[string]string `json:"args" validate:"required"`
Fault apperror.Fault `json:"fault" validate:"required"`
RequestID string `json:"request_id,omitempty"`
TraceID string `json:"trace_id,omitempty"`
}
Problem is the RFC 9457 body of an HTTP error response. Fault and TraceID are filled by the HTTP boundary: fault is its attribution of the error (client, server, dependency or canceled), which a client uses to choose generic copy for a code it does not know.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
type StreamError ¶ added in v0.22.0
type StreamError struct {
Type string `json:"type" enums:"error"`
Code string `json:"code"`
Args map[string]string `json:"args"`
Detail string `json:"detail"`
// Message repeats Detail. A Web client recognizes an error event by it.
Message string `json:"message"`
Fault apperror.Fault `json:"fault"`
RequestID string `json:"request_id,omitempty"`
}
StreamError is the error event of a stream that is already open: an SSE error frame or a WebSocket error frame. It carries the public error the HTTP error handler would answer with, and never the error's own text.
func NewStreamError ¶ added in v0.22.0
NewStreamError is the error event for err, chosen by errs.Answer, and the error the event was rendered from. A handler that sends the event returns that error, so that the request's result record attributes it; it does not log it itself.