echo

package
v0.1.3 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 21, 2026 License: MIT Imports: 16 Imported by: 0

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

Constants

This section is empty.

Variables

This section is empty.

Functions

func BearerToken

func BearerToken(c *base.Context) string

BearerToken extracts the Bearer token from the Authorization header, returning an empty string if not present.

func GetSentryHub

func GetSentryHub(c *base.Context) *sentry.Hub

GetSentryHub returns the per-request Sentry hub stored in the echo context, or nil when Sentry is not configured.

func HTTPErrorHandler

func HTTPErrorHandler(c *base.Context, err error)

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

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.

Types

type Server

type Server struct {
	// contains filtered or unexported fields
}

func NewServer

func NewServer(e *base.Echo, c ServerConfig, l logger.Logger) *Server

func (*Server) Start

func (s *Server) Start(ctx context.Context) error

func (*Server) Stop

func (s *Server) Stop(ctx context.Context) error

type ServerConfig

type ServerConfig struct {
	Hosts             []string
	ReadTimeout       int
	WriteTimeout      int
	ReadHeaderTimeout int
	IdleTimeout       int
}

ServerConfig holds HTTP server listen addresses and timeouts (seconds).

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL