gateway

package
v1.2.0 Latest Latest
Warning

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

Go to latest
Published: Jan 25, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func AuthInterceptor

func AuthInterceptor(logger *log.Logger) grpc.UnaryServerInterceptor

AuthInterceptor handles authentication and authorization

func ClientCertMiddleware

func ClientCertMiddleware(next http.Handler) http.Handler

ClientCertMiddleware validates client certificates for HTTP requests

func HealthCheckHandler

func HealthCheckHandler() http.Handler

HealthCheckHandler provides a simple health check endpoint

func InitMetrics

func InitMetrics()

InitMetrics initializes the global metrics registry

func LoggingInterceptor

func LoggingInterceptor(logger *log.Logger) grpc.UnaryServerInterceptor

LoggingInterceptor logs all gRPC requests and responses

func MetricsHandler

func MetricsHandler() http.Handler

MetricsHandler provides a Prometheus metrics endpoint

func MetricsInterceptor

func MetricsInterceptor(logger *log.Logger) grpc.UnaryServerInterceptor

MetricsInterceptor collects metrics for gRPC requests

func NewHTTPGateway

func NewHTTPGateway(ctx context.Context, config GatewayConfig, logger *log.Logger) (http.Handler, error)

NewHTTPGateway creates a new HTTP-to-gRPC gateway

func RateLimitingInterceptor

func RateLimitingInterceptor(logger *log.Logger, requestsPerSecond int) grpc.UnaryServerInterceptor

RateLimitingInterceptor implements basic rate limiting

func RecoveryInterceptor

func RecoveryInterceptor(logger *log.Logger) grpc.UnaryServerInterceptor

RecoveryInterceptor recovers from panics and returns appropriate errors

func SwaggerSpecHandler

func SwaggerSpecHandler(config GatewayConfig, logger *log.Logger) http.Handler

SwaggerSpecHandler serves the OpenAPI specification JSON

func SwaggerUIHandler

func SwaggerUIHandler(config GatewayConfig, logger *log.Logger) http.Handler

SwaggerUIHandler serves the Swagger UI for API documentation

func ValidationInterceptor

func ValidationInterceptor(logger *log.Logger) grpc.UnaryServerInterceptor

ValidationInterceptor validates incoming requests

func VerifyPeerCertificateInterceptor

func VerifyPeerCertificateInterceptor(ctx context.Context, req interface{}, info *grpc.UnaryServerInfo, handler grpc.UnaryHandler) (interface{}, error)

VerifyPeerCertificateInterceptor validates client certificates for gRPC requests

Types

type GatewayConfig

type GatewayConfig struct {
	GRPCServerAddr string
	HTTPAddr       string
	CORSEnabled    bool
	AllowedOrigins []string

	// TLS Configuration for gateway→gRPC connection
	UseTLS         bool   // Enable TLS for internal gateway→gRPC connection
	TLSInsecure    bool   // Skip TLS verification (for localhost)
	ServerCertFile string // Optional: CA cert to verify server certificate

	// API Documentation Configuration
	EnableAPIDocs       bool     // Enable API documentation endpoints (disabled by default in production)
	APIDocsAllowOrigins []string // Allowed CORS origins for API docs (empty = use AllowedOrigins)
}

GatewayConfig holds configuration for the HTTP gateway

Jump to

Keyboard shortcuts

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