Documentation
¶
Overview ¶
Package visgin connects vis to gin: every request carries a snapshot of the knobs and is timed under its route pattern, as with vis.HTTP. It is its own module, so vis itself never depends on gin.
r := gin.Default()
r.Use(visgin.Middleware())
r.POST("/api/generate", func(c *gin.Context) {
n := MaxLoaded.From(c.Request.Context())
…
})
A // vis:slo directive above a handler registered this way names its route as the middleware does, "POST /api/generate", and vis gen finds it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Middleware ¶
func Middleware() gin.HandlerFunc
Middleware is MiddlewareIn for the default instance, the one vis.Start serves.
func MiddlewareIn ¶
func MiddlewareIn(in *vis.Instance) gin.HandlerFunc
MiddlewareIn puts a snapshot of in's knobs in each request's context and times the request under "METHOD /route/:pattern", the way gin's FullPath names it. Requests gin can't route count under one route, so paths never become routes. Use it after gin.Recovery, as gin.Default has it, so a panic counts as the 500 Recovery sends.
Types ¶
This section is empty.