1
0
Fork 0
mirror of https://github.com/portainer/portainer.git synced 2025-07-25 08:19:40 +02:00

feat(featureflags): improved feature flag handling [EE-4609] (#8222)

* updated and improved feature flags using new module

* merge init into parse

* update the package documentation

* better docs

* minor tidy
This commit is contained in:
Matt Hook 2023-02-09 17:17:46 +13:00 committed by GitHub
parent 51b9804fab
commit bfc610c192
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
15 changed files with 257 additions and 184 deletions

View file

@ -5,14 +5,14 @@ import (
"github.com/gorilla/mux"
httperror "github.com/portainer/libhttp/error"
portainer "github.com/portainer/portainer/api"
"github.com/portainer/portainer/api/dataservices"
"github.com/portainer/portainer/pkg/featureflags"
)
func FeatureFlag(settingsService dataservices.SettingsService, feature portainer.Feature) mux.MiddlewareFunc {
func FeatureFlag(settingsService dataservices.SettingsService, feature featureflags.Feature) mux.MiddlewareFunc {
return func(next http.Handler) http.Handler {
return http.HandlerFunc(func(rw http.ResponseWriter, request *http.Request) {
enabled := settingsService.IsFeatureFlagEnabled(feature)
enabled := featureflags.IsEnabled(feature)
if !enabled {
httperror.WriteError(rw, http.StatusForbidden, "This feature is not enabled", nil)