context

package
v0.10.0 Latest Latest
Warning

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

Go to latest
Published: Dec 5, 2025 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ServiceContextMiddleware

func ServiceContextMiddleware[T any](logger *zap.Logger, tracer *trace.Tracer, props T) echo.MiddlewareFunc

ServiceContextMiddleware injects objects to echo.Context.

Types

type ServiceContext

type ServiceContext[T any] struct {
	echo.Context
	ZapLogger *zap.Logger
	Tracer    *trace.Tracer
	// Props would be shared across all requests in the service
	Props T
	// RequestProps values are unique to each requests
	RequestProps map[string]interface{}
}

ServiceContext contains the echo.Context and custom properties vital for a microservice.

func GetServiceContext

func GetServiceContext[T any](ctx echo.Context) *ServiceContext[T]

GetServiceContext returns the ServiceContext from echo.Context.

func (*ServiceContext[T]) BindValidate

func (c *ServiceContext[T]) BindValidate(i interface{}) error

BindValidate binds the data to the given interface and validates the input given using validator/10.

Jump to

Keyboard shortcuts

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