Documentation
¶
Index ¶
- func BasicAuthHandler(userid, passwd string, next func(ctx *gin.Context)) gin.HandlerFunc
- type MetricAdapter
- func (obj *MetricAdapter) Code(ctx *gin.Context) int
- func (obj *MetricAdapter) Handler(ctx *gin.Context) string
- func (obj *MetricAdapter) Method(ctx *gin.Context) string
- func (obj *MetricAdapter) Middleware(metrics metrics.Metrics) gin.HandlerFunc
- func (obj *MetricAdapter) Reporter(ctx *gin.Context, start time.Time, requestBytes int64) metrics.MetricData
- func (obj *MetricAdapter) RequestBytes(ctx *gin.Context) int64
- func (obj *MetricAdapter) ResponseBytes(ctx *gin.Context) int64
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func BasicAuthHandler ¶
func BasicAuthHandler(userid, passwd string, next func(ctx *gin.Context)) gin.HandlerFunc
BasicAuthHandler returns an HTTP handler function that performs basic authentication using the provided userid and password. It checks the request's basic authentication credentials and responds with a 401 Unauthorized status if the credentials are invalid.
Types ¶
type MetricAdapter ¶
type MetricAdapter struct {
// contains filtered or unexported fields
}
MetricAdapter is the Gin MetricAdapter.
func NewMetricsAdapter ¶
func NewMetricsAdapter(reqKey string) *MetricAdapter
NewMetricsAdapter is the default Gin MetricAdapter.
func (*MetricAdapter) Middleware ¶
func (obj *MetricAdapter) Middleware(metrics metrics.Metrics) gin.HandlerFunc
Middleware is the Gin MetricAdapter function that logs Handler requests and their details.
It takes the following parameters: enable: bool, whether to enable the middleware or not. reqKey: string, the key to retrieve the received bytes from the context.
func (*MetricAdapter) Reporter ¶
func (obj *MetricAdapter) Reporter(ctx *gin.Context, start time.Time, requestBytes int64) metrics.MetricData
Reporter is the Gin MetricAdapter function that logs Handler requests and their details.
func (*MetricAdapter) RequestBytes ¶
func (obj *MetricAdapter) RequestBytes(ctx *gin.Context) int64
func (*MetricAdapter) ResponseBytes ¶
func (obj *MetricAdapter) ResponseBytes(ctx *gin.Context) int64