.post("/admin/set", new Middleware() {
@Override
public void handle(final YokeRequest request, final Handler<Object> next) {
final Config.Domain domain = request.get("domain");
MultiMap body = request.formAttributes();
String key = body.get("key");
String value = body.get("value");
if (key == null) {
request.response().end("Missing key");
return;
}
if (value == null) {
request.response().end("Missing value");
return;
}
db.set(domain.namespace + "&" + key, value, new Handler<Message<JsonObject>>() {
@Override
public void handle(Message<JsonObject> message) {
if (!"ok".equals(message.body().getString("status"))) {
next.handle(message.body().getString("message"));
} else {
request.response().setContentType("application/json");
request.response().end("\"OK\"");
}
}
});
}
})
.post("/admin/unset", new Middleware() {
@Override
public void handle(final YokeRequest request, final Handler<Object> next) {
final Config.Domain domain = request.get("domain");
MultiMap body = request.formAttributes();
String key = body.get("key");
if (key == null) {
request.response().end("Missing key");
return;
}