add a flag to allow and disable sites (http.disable_sites)

This commit is contained in:
kimchy 2011-05-28 19:04:46 +03:00
parent 94434a7522
commit 3025205063
1 changed files with 8 additions and 0 deletions

View File

@ -49,6 +49,8 @@ public class HttpServer extends AbstractLifecycleComponent<HttpServer> {
private final TransportNodesInfoAction nodesInfoAction;
private final boolean disableSites;
@Inject public HttpServer(Settings settings, Environment environment, HttpServerTransport transport,
RestController restController, TransportNodesInfoAction nodesInfoAction) {
super(settings);
@ -57,6 +59,8 @@ public class HttpServer extends AbstractLifecycleComponent<HttpServer> {
this.restController = restController;
this.nodesInfoAction = nodesInfoAction;
this.disableSites = componentSettings.getAsBoolean("disable_sites", false);
transport.httpServerAdapter(new Dispatcher(this));
}
@ -107,6 +111,10 @@ public class HttpServer extends AbstractLifecycleComponent<HttpServer> {
}
private void handlePluginSite(HttpRequest request, HttpChannel channel) {
if (disableSites) {
channel.sendResponse(new StringRestResponse(FORBIDDEN));
return;
}
if (request.method() != RestRequest.Method.GET) {
channel.sendResponse(new StringRestResponse(FORBIDDEN));
return;