http

package
v0.5.0 Latest Latest
Warning

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

Go to latest
Published: Jul 11, 2026 License: MIT Imports: 8 Imported by: 0

README

internal/delivery/http

Pattern used

  • Adapter pattern from HTTP transport to usecase calls.
  • server.go owns Echo setup, global middleware, and route registration.
  • Handlers under handler/<feature>/, files named <feature>_<role>.go (e.g. auth_handler.go, auth_dto.go).
  • OpenAPI-generated models in openapi/gen/ from docs/openapi.yaml.
  • Request binding normalization in binding/, injected as the server's Binder.
  • Request-scoped Echo context values (session, response metadata for observability) live in httpcontext/ so handlers and middleware share one place for Set/Get helpers.

How to extend

  • Add handler/<feature>/ with <feature>_handler.go, <feature>_dto.go, etc.
  • Register routes via RouteRegistrar.
  • Update docs/openapi.yaml and run make openapi-generate for contract changes.
  • Keep handlers thin: bind/validate -> call usecase -> map response.

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type RouteRegistrar

type RouteRegistrar interface {
	RegisterRoutes(e *echo.Echo)
}

RouteRegistrar lets each handler/module register its own routes.

type Server

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

func NewServer

func NewServer(cfg ServerConfig, log logger.Logger, binder echo.Binder, validatorRegistrars []ValidationRegistrar, middlewares []echo.MiddlewareFunc, registrars ...RouteRegistrar) (*Server, error)

func (*Server) ServeHTTP added in v0.5.0

func (s *Server) ServeHTTP(w http.ResponseWriter, r *http.Request)

ServeHTTP dispatches requests through the configured Echo handler.

func (*Server) Shutdown

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

func (*Server) Start

func (s *Server) Start() error

type ServerConfig

type ServerConfig struct {
	Address      string
	ReadTimeout  time.Duration
	WriteTimeout time.Duration
	IdleTimeout  time.Duration
	IPExtractor  echo.IPExtractor
}

ServerConfig holds HTTP server settings. Filled by app from infra config so delivery does not depend on infra.

type ValidationRegistrar

type ValidationRegistrar func(v *validator.Validate) error

Directories

Path Synopsis
Package binding provides Echo binding helpers.
Package binding provides Echo binding helpers.
handler
middleware
openapi
gen
Package openapi provides primitives to interact with the openapi HTTP API.
Package openapi provides primitives to interact with the openapi HTTP API.

Jump to

Keyboard shortcuts

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