MCPcopy Create free account
hub / github.com/imgproxy/imgproxy / StartRequestTimer

Function StartRequestTimer

server/timer.go:15–20  ·  view source on GitHub ↗

StartRequestTimer starts a new request timer.

(r *http.Request, timeout time.Duration)

Source from the content-addressed store, hash-verified

13
14// StartRequestTimer starts a new request timer.
15func StartRequestTimer(r *http.Request, timeout time.Duration) (*http.Request, context.CancelFunc) {
16 ctx := r.Context()
17 ctx = context.WithValue(ctx, timerSinceCtxKey{}, time.Now())
18 ctx, cancel := context.WithTimeout(ctx, timeout) //nolint:gosec // cancel is called
19 return r.WithContext(ctx), cancel
20}
21
22// RequestDuration returns the duration since the timer started in the context.
23func RequestDuration(ctx context.Context) time.Duration {

Callers 2

TestCheckTimeoutFunction · 0.92
ServeHTTPMethod · 0.85

Calls

no outgoing calls

Tested by 1

TestCheckTimeoutFunction · 0.74