diff options
Diffstat (limited to 'lib/api/feature_flags.rb')
-rw-r--r-- | lib/api/feature_flags.rb | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/lib/api/feature_flags.rb b/lib/api/feature_flags.rb new file mode 100644 index 00000000000..dff43544a75 --- /dev/null +++ b/lib/api/feature_flags.rb @@ -0,0 +1,50 @@ +module API + class FeatureFlags < Grape::API + include PaginationParams + + resource :feature_flags do + resource :projects, requirements: API::PROJECT_ENDPOINT_REQUIREMENTS do + params do + requires :id, type: String, desc: 'The ID of a project' + end + route_param :id do + resource :unleash do + before do + authenticate_by_unleash_access_token! + end + + get 'features' do + present project, with: Entities::UnleashFeatures + end + + post 'client/register' do + # not supported yet + status :ok + end + + post 'client/metrics' do + # not supported yet + status :ok + end + end + end + end + + helpers do + def project + @project ||= find_project(params[:id]) + end + + def unleash_instanceid + params[:instanceid] || env[:HTTP_UNLEASH_INSTANCEID] + end + + def authenticate_by_unleash_access_token! + unless Operations::FeatureFlagsAccessToken.find_by(token: unleash_instanceid, project: project) + unauthorized! + end + end + end + end + end +end |