modulepackage
1.1.3
Repository: https://github.com/elvenworks/go-middleware.git
Documentation: pkg.go.dev
# README
Package go-middleware is a collection of middlewares for the Gin web framework to be used in Elvenworks applications.
Installation
Use go get.
go get github.com/elvenworks/go-middleware
Then import the validator package into your own code.
import "github.com/elvenworks/go-middleware"
Usage logger
Sample code:
import (
middleware "github.com/elvenworks/go-middleware"
)
func InitRoutes() {
skipPaths := []string{
"/docs",
"/api/private/v1/healthz",
"/metrics",
}
logger := middleware.NewLogger(skipPaths, logs.GetLoggerLevel())
logger.Use(httpServer.Router)
}
Usage prometheus
Sample code:
import (
middleware "github.com/elvenworks/go-middleware"
)
func InitRoutes() {
p := middleware.NewPrometheus("gin")
p.Use(httpServer.Router)
}
Usage auth_jwt
Sample code:
import (
middleware "github.com/elvenworks/go-middleware"
)
func New() *HTTP {
router := gin.New()
router.Use(middleware.NewAuthJWT())
}
# Functions
No description provided by the author
No description provided by the author
NewMetric associates prometheus.Collector based on Metric.Type.
NewPrometheus generates a new set of metrics with a certain subsystem name.
No description provided by the author
# Structs
No description provided by the author
No description provided by the author
No description provided by the author
Metric is a definition for the name, description, type, ID, and prometheus.Collector type (i.e.
Prometheus contains the metrics gathered by the instance and its path.
PrometheusPushGateway contains the configuration for pushing to a Prometheus pushgateway (optional).
# Type aliases
RequestCounterURLLabelMappingFn is a function which can be supplied to the middleware to control
the cardinality of the request counter's "url" label, which might be required in some contexts.