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

Function ExtractExternalAuthParam

coderd/httpmw/externalauthparam.go:23–40  ·  view source on GitHub ↗
(configs []*externalauth.Config)

Source from the content-addressed store, hash-verified

21}
22
23func ExtractExternalAuthParam(configs []*externalauth.Config) func(next http.Handler) http.Handler {
24 configByID := make(map[string]*externalauth.Config)
25 for _, c := range configs {
26 configByID[c.ID] = c
27 }
28 return func(next http.Handler) http.Handler {
29 return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
30 config, ok := configByID[chi.URLParam(r, "externalauth")]
31 if !ok {
32 httpapi.ResourceNotFound(w)
33 return
34 }
35
36 r = r.WithContext(context.WithValue(r.Context(), externalAuthParamContextKey{}, config))
37 next.ServeHTTP(w, r)
38 })
39 }
40}

Callers 1

TestExternalAuthParamFunction · 0.92

Calls 4

ResourceNotFoundFunction · 0.92
WithContextMethod · 0.80
ContextMethod · 0.65
ServeHTTPMethod · 0.45

Tested by 1

TestExternalAuthParamFunction · 0.74