http

package
v0.4.0 Latest Latest
Warning

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

Go to latest
Published: Feb 18, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package http provides HTTP server implementation and request handlers.

Package http provides HTTP server implementation and request handlers using Gin web framework. The server uses Clean Architecture principles with structured logging (slog) and graceful shutdown.

This server uses Gin (github.com/gin-gonic/gin) for HTTP routing while maintaining compatibility with the application's existing patterns:

  • Custom slog-based logging middleware (instead of Gin's default logger)
  • Gin-compatible error handling utilities (httputil.HandleErrorGin)
  • Manual http.Server configuration for timeout and graceful shutdown control

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CustomLoggerMiddleware

func CustomLoggerMiddleware(logger *slog.Logger) gin.HandlerFunc

CustomLoggerMiddleware provides structured logging using slog. This replaces Gin's default logger to maintain consistency with the application's existing logging patterns.

Types

type Server

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

Server represents the HTTP server.

func NewServer

func NewServer(
	host string,
	port int,
	logger *slog.Logger,
) *Server

NewServer creates a new HTTP server.

func (*Server) GetHandler

func (s *Server) GetHandler() http.Handler

GetHandler returns the http.Handler for testing purposes. Returns nil if SetupRouter has not been called yet.

func (*Server) SetupRouter

func (s *Server) SetupRouter(
	clientHandler *authHTTP.ClientHandler,
	tokenHandler *authHTTP.TokenHandler,
	auditLogHandler *authHTTP.AuditLogHandler,
	secretHandler *secretsHTTP.SecretHandler,
	transitKeyHandler *transitHTTP.TransitKeyHandler,
	cryptoHandler *transitHTTP.CryptoHandler,
	tokenizationKeyHandler *tokenizationHTTP.TokenizationKeyHandler,
	tokenizationHandler *tokenizationHTTP.TokenizationHandler,
	tokenUseCase authUseCase.TokenUseCase,
	tokenService authService.TokenService,
	auditLogUseCase authUseCase.AuditLogUseCase,
	metricsProvider *metrics.Provider,
	metricsNamespace string,
)

SetupRouter configures the Gin router with all routes and middleware. This method is called during server initialization with all required dependencies.

func (*Server) Shutdown

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

Shutdown gracefully shuts down the HTTP server.

func (*Server) Start

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

Start starts the HTTP server.

Jump to

Keyboard shortcuts

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