MCPcopy Index your code
hub / github.com/coder/coder / CustomRoleMW

Function CustomRoleMW

coderd/rbac/rolestore/rolestore.go:21–26  ·  view source on GitHub ↗

CustomRoleMW adds a custom role cache on the ctx to prevent duplicate db fetches.

(next http.Handler)

Source from the content-addressed store, hash-verified

19// CustomRoleMW adds a custom role cache on the ctx to prevent duplicate
20// db fetches.
21func CustomRoleMW(next http.Handler) http.Handler {
22 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
23 r = r.WithContext(CustomRoleCacheContext(r.Context()))
24 next.ServeHTTP(w, r)
25 })
26}
27
28// CustomRoleCacheContext prevents needing to lookup custom roles within the
29// same request lifecycle. Optimizing this to span requests should be done

Callers

nothing calls this directly

Calls 4

CustomRoleCacheContextFunction · 0.85
WithContextMethod · 0.80
ContextMethod · 0.65
ServeHTTPMethod · 0.45

Tested by

no test coverage detected