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

Method RequireFeatureMW

enterprise/coderd/templates.go:352–367  ·  view source on GitHub ↗
(feat codersdk.FeatureName)

Source from the content-addressed store, hash-verified

350}
351
352func (api *API) RequireFeatureMW(feat codersdk.FeatureName) func(http.Handler) http.Handler {
353 return func(next http.Handler) http.Handler {
354 return http.HandlerFunc(func(rw http.ResponseWriter, r *http.Request) {
355 // Entitlement must be enabled.
356 if !api.Entitlements.Enabled(feat) {
357 // All feature warnings should be "Premium", not "Enterprise".
358 httpapi.Write(r.Context(), rw, http.StatusForbidden, codersdk.Response{
359 Message: fmt.Sprintf("%s is a Premium feature. Contact sales!", feat.Humanize()),
360 })
361 return
362 }
363
364 next.ServeHTTP(rw, r)
365 })
366 }
367}
368
369// @Summary Invalidate presets for template
370// @ID invalidate-presets-for-template

Callers 4

NewFunction · 0.95
templateRBACEnabledMWMethod · 0.95
aibridgeproxyHandlerFunction · 0.80
aibridgeHandlerFunction · 0.80

Calls 5

WriteFunction · 0.92
EnabledMethod · 0.65
ContextMethod · 0.65
HumanizeMethod · 0.45
ServeHTTPMethod · 0.45

Tested by

no test coverage detected