(feat codersdk.FeatureName)
| 350 | } |
| 351 | |
| 352 | func (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 |
no test coverage detected