mirror of
https://github.com/Unleash/unleash.git
synced 2025-01-01 00:08:27 +01:00
add toggle endpoint
This commit is contained in:
parent
53f94058bd
commit
1f5b1c1925
@ -99,6 +99,23 @@ module.exports = function (app, config) {
|
|||||||
.catch(error => handleErrors(req, res, error));
|
.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) => {
|
app.delete('/features/:featureName', (req, res) => {
|
||||||
const featureName = req.params.featureName;
|
const featureName = req.params.featureName;
|
||||||
const userName = extractUser(req);
|
const userName = extractUser(req);
|
||||||
|
Loading…
Reference in New Issue
Block a user