this.handlers = handlers;
}
@Override
public void handle(Context context) throws Exception {
HttpMethod method = context.getRequest().getMethod();
if (method.isOptions()) {
String methods = Joiner.on(",").join(handlers.keySet());
context.getResponse().getHeaders().add(HttpHeaderConstants.ALLOW, methods);
context.getResponse().status(200).send();
} else {
for (Map.Entry<String, Handler> entry : handlers.entrySet()) {
String key = entry.getKey();
if (method.name(key)) {
entry.getValue().handle(context);
return;
}
}