Documentation ¶
Index ¶
- Constants
- Variables
- func DecrementModifier(value any) (any, error)
- func IpCaster(value any) (any, error)
- func ValueOrZeroModifier(value any) (any, error)
- type Caster
- type DurationMetric
- type Getter
- type Modifier
- type Option
- func AddGetter(getter Getter) Option
- func WithChiURLParam(name string) Option
- func WithCookie(name string) Option
- func WithDefault(value any) Option
- func WithHeader(name string) Option
- func WithModifier(modifier Modifier) Option
- func WithName(name string) Option
- func WithUri(name string) Option
- func WithValidator(validator Validator) Option
- type Param
- func NewIp(logger logger.Logger) *Param
- func NewPagination(logger logger.Logger, allowedColumns ...string) []*Param
- func NewPaginationLimit(logger logger.Logger) *Param
- func NewPaginationPage(logger logger.Logger) *Param
- func NewPaginationSortColumn(logger logger.Logger, allowedColumns ...string) *Param
- func NewPaginationSortDirection(logger logger.Logger) *Param
- func NewParam(logger logger.Logger, caster Caster, options ...Option) *Param
- func NewParamBool(logger logger.Logger, options ...Option) *Param
- func NewParamDuration(logger logger.Logger, options ...Option) *Param
- func NewParamFloat32(logger logger.Logger, options ...Option) *Param
- func NewParamFloat64(logger logger.Logger, options ...Option) *Param
- func NewParamInt(logger logger.Logger, options ...Option) *Param
- func NewParamInt16(logger logger.Logger, options ...Option) *Param
- func NewParamInt32(logger logger.Logger, options ...Option) *Param
- func NewParamInt64(logger logger.Logger, options ...Option) *Param
- func NewParamInt8(logger logger.Logger, options ...Option) *Param
- func NewParamString(logger logger.Logger, options ...Option) *Param
- func NewParamTime(logger logger.Logger, options ...Option) *Param
- func NewParamUUID(logger logger.Logger, options ...Option) *Param
- func NewParamUint(logger logger.Logger, options ...Option) *Param
- func NewParamUint16(logger logger.Logger, options ...Option) *Param
- func NewParamUint32(logger logger.Logger, options ...Option) *Param
- func NewParamUint64(logger logger.Logger, options ...Option) *Param
- func NewParamUint8(logger logger.Logger, options ...Option) *Param
- type RequestLogger
- type ResponseLogger
- type TotalRequestCount
- type Validator
Constants ¶
View Source
const ( PageFieldName = "page" LimitFieldName = "limit" SortColumnFieldName = "colSort" SortDirectionFieldName = "direction" CountHeaderName = "X-Pagination-Count" PageHeaderName = "X-Pagination-Page" LimitHeaderName = "X-Pagination-Limit" SortColumnHeaderName = "X-Pagination-Sort-Column" SortDirectionHeaderName = "X-Pagination-Sort-Direction" SortDirectionAsc = "asc" SortDirectionDesc = "desc" SortColumnDefault = "id" LimitDefault = uint8(20) PageDefault = uint32(1) IpFieldName = "ip" HeaderRealIp = "X-REAL-IP" HeaderForwardedFor = "X-FORWARDED-FOR" )
Variables ¶
View Source
var ( MetricTotalRequestCountComponent = &app.Component{ Dependencies: app.Components{ logger.Component, router.Component, }, Constructor: app.Constructor(func(container container.Container) error { return container.Provide(NewTotalRequestCount) }), Run: app.Run(func(container container.Container) error { return container.Invoke(func( metric *TotalRequestCount, router router.Router, informer logger.Informer, ) { informer.Info("http.server.middleware: added a metric for the total number of requests") router.Use(metric) }) }), } MetricDurationComponent = &app.Component{ Dependencies: app.Components{ logger.Component, router.Component, }, Constructor: app.Constructor(func(container container.Container) error { return container.Provide(NewDurationMetric) }), Run: app.Run(func(container container.Container) error { return container.Invoke(func( metric *DurationMetric, router router.Router, informer logger.Informer, ) { informer.Info("http.server.middleware: added metric of query execution time counter") router.Use(metric) }) }), } ResponseLoggerComponent = &app.Component{ Dependencies: app.Components{ logger.Component, router.Component, }, Constructor: app.Constructor(func(container container.Container) error { return container.Provide(NewResponseLogger) }), Run: app.Run(func(container container.Container) error { return container.Invoke(func( loggerMiddleware *ResponseLogger, router router.Router, informer logger.Informer, ) { informer.Info("http.server.middleware: added response logger") router.Use(loggerMiddleware) }) }), } RequestLoggerComponent = &app.Component{ Dependencies: app.Components{ logger.Component, router.Component, }, Constructor: app.Constructor(func(container container.Container) error { return container.Provide(NewRequestLogger) }), Run: app.Run(func(container container.Container) error { return container.Invoke(func( loggerMiddleware *RequestLogger, router router.Router, informer logger.Informer, ) { informer.Info("http.server.middleware: added request logger") router.Use(loggerMiddleware) }) }), } Component = &app.Component{ Dependencies: app.Components{ MetricTotalRequestCountComponent, MetricDurationComponent, ResponseLoggerComponent, RequestLoggerComponent, }, } )
Functions ¶
func DecrementModifier ¶
func ValueOrZeroModifier ¶
Types ¶
type DurationMetric ¶
type DurationMetric struct {
// contains filtered or unexported fields
}
func NewDurationMetric ¶
func NewDurationMetric(appConfig *app.Config) *DurationMetric
func (*DurationMetric) Middleware ¶
func (middleware *DurationMetric) Middleware(next http.Handler) http.Handler
type Option ¶
func WithChiURLParam ¶
func WithCookie ¶
func WithDefault ¶
func WithHeader ¶
func WithModifier ¶
func WithValidator ¶
type Param ¶
type Param struct {
// contains filtered or unexported fields
}
func NewPaginationLimit ¶
func NewPaginationPage ¶
func NewPaginationSortColumn ¶
type RequestLogger ¶
type RequestLogger struct {
// contains filtered or unexported fields
}
func NewRequestLogger ¶
func NewRequestLogger(logger logger.Logger) *RequestLogger
func (*RequestLogger) Middleware ¶
func (r *RequestLogger) Middleware(next http.Handler) http.Handler
type ResponseLogger ¶
type ResponseLogger struct {
// contains filtered or unexported fields
}
func NewResponseLogger ¶
func NewResponseLogger(logger logger.Logger) *ResponseLogger
func (*ResponseLogger) Middleware ¶
func (r *ResponseLogger) Middleware(next http.Handler) http.Handler
type TotalRequestCount ¶
type TotalRequestCount struct {
// contains filtered or unexported fields
}
func NewTotalRequestCount ¶
func NewTotalRequestCount(appConfig *app.Config) *TotalRequestCount
func (*TotalRequestCount) Middleware ¶
func (middleware *TotalRequestCount) Middleware(next http.Handler) http.Handler
Click to show internal directories.
Click to hide internal directories.