From 1f5b1c192555f361c864e6147972b3aeba0d75ba Mon Sep 17 00:00:00 2001 From: sveisvei Date: Sun, 8 Jan 2017 20:04:46 +0100 Subject: [PATCH] add toggle endpoint --- lib/routes/feature.js | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/lib/routes/feature.js b/lib/routes/feature.js index 458ee98d1d..356c846364 100644 --- a/lib/routes/feature.js +++ b/lib/routes/feature.js @@ -99,6 +99,23 @@ module.exports = function (app, config) { .catch(error => handleErrors(req, res, error)); }); + app.put('/features/:featureName/toggle', (req, res) => { + const featureName = req.params.featureName; + const userName = extractUser(req); + + featureToggleStore.getFeature(featureName) + .then((feature) => { + feature.enabled = !feature.enabled; + return eventStore.store({ + type: FEATURE_UPDATED, + createdBy: userName, + data: feature, + }); + }) + .then(() => res.status(200).end()) + .catch(error => handleErrors(req, res, error)); + }); + app.delete('/features/:featureName', (req, res) => { const featureName = req.params.featureName; const userName = extractUser(req);