MCPcopy Create free account
hub / github.com/gotenberg/gotenberg / latencyMiddleware

Function latencyMiddleware

pkg/modules/api/middlewares.go:110–121  ·  view source on GitHub ↗

latencyMiddleware sets the start time in the [echo.Context] under "startTime". Its value will be used later to calculate request latency. startTime := c.Get("startTime").(time.Time)

()

Source from the content-addressed store, hash-verified

108//
109// startTime := c.Get("startTime").(time.Time)
110func latencyMiddleware() echo.MiddlewareFunc {
111 return func(next echo.HandlerFunc) echo.HandlerFunc {
112 return func(c echo.Context) error {
113 // First piece for calculating the latency.
114 startTime := time.Now()
115 c.Set("startTime", startTime)
116
117 // Call the next middleware in the chain.
118 return next(c)
119 }
120 }
121}
122
123// rootPathMiddleware sets the root path in the [echo.Context] under
124// "rootPath". Its value may be used to skip a middleware execution based on a

Callers 1

StartMethod · 0.85

Calls 1

SetMethod · 0.80

Tested by

no test coverage detected