1
0
mirror of https://github.com/Unleash/unleash.git synced 2024-12-22 19:07:54 +01:00

add toggle endpoint

This commit is contained in:
sveisvei 2017-01-08 20:04:46 +01:00 committed by Ivar Conradi Østhus
parent a455e0a68c
commit 32a0b93096

View File

@ -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);