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:
parent
a455e0a68c
commit
32a0b93096
@ -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);
|
||||
|
Loading…
Reference in New Issue
Block a user