Documentation
¶
Overview ¶
Package echo provides the shared Echo HTTP stack: instance assembly, apperror-aware error handling, request logging, Sentry integration, the HTTP server lifecycle, and actor guard middlewares.
Index ¶
- func Authenticator[U any](a authentication.Authenticator[U]) base.MiddlewareFunc
- func BearerToken(c *base.Context) string
- func GetSentryHub(c *base.Context) *sentry.Hub
- func HTTPErrorHandler(c *base.Context, err error)
- func Logger(l logger.Logger) base.MiddlewareFunc
- func NewEcho[U any](v validator.Validator, l logger.Logger, a authentication.Authenticator[U]) *base.Echo
- func RequireAdmin(next base.HandlerFunc) base.HandlerFunc
- func RequireService(next base.HandlerFunc) base.HandlerFunc
- func RequireUser(next base.HandlerFunc) base.HandlerFunc
- func Sentry() base.MiddlewareFunc
- type Server
- type ServerConfig
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Authenticator ¶
func Authenticator[U any](a authentication.Authenticator[U]) base.MiddlewareFunc
func BearerToken ¶
BearerToken extracts the Bearer token from the Authorization header, returning an empty string if not present.
func GetSentryHub ¶
GetSentryHub returns the per-request Sentry hub stored in the echo context, or nil when Sentry is not configured.
func HTTPErrorHandler ¶
HTTPErrorHandler maps apperror types to HTTP statuses and reports unexpected errors to Sentry.
func Logger ¶
func Logger(l logger.Logger) base.MiddlewareFunc
Logger emits structured logs for every HTTP request.
func NewEcho ¶
func NewEcho[U any](v validator.Validator, l logger.Logger, a authentication.Authenticator[U]) *base.Echo
NewEcho creates a fully configured Echo instance with the standard middleware stack.
func RequireAdmin ¶
func RequireAdmin(next base.HandlerFunc) base.HandlerFunc
RequireAdmin returns 401 if unauthenticated, 403 if the actor is not an admin.
func RequireService ¶
func RequireService(next base.HandlerFunc) base.HandlerFunc
RequireService returns 401 if unauthenticated, 403 if the actor is not a service.
func RequireUser ¶
func RequireUser(next base.HandlerFunc) base.HandlerFunc
RequireUser returns 401 if no authenticated actor is in context.
func Sentry ¶
func Sentry() base.MiddlewareFunc
Sentry returns a middleware that attaches a per-request Sentry hub to the echo context and captures any panics before the Recover middleware handles them.