Skip to content

Instantly share code, notes, and snippets.

@katta
Created December 21, 2012 11:37
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save katta/4352302 to your computer and use it in GitHub Desktop.
Save katta/4352302 to your computer and use it in GitHub Desktop.
Custom REST handler for Elastic Search
package org.katta.es.http;
import org.elasticsearch.client.Client;
import org.elasticsearch.common.inject.Inject;
import org.elasticsearch.common.settings.Settings;
import org.elasticsearch.rest.*;
public class RestRegisterAction extends BaseRestHandler {
@Inject
protected RestRegisterAction(Settings settings, Client client, RestController controller) {
super(settings, client);
controller.registerHandler(RestRequest.Method.POST, "/register", this);
}
@Override
public void handleRequest(RestRequest request, RestChannel channel) {
String user = request.param("user");
System.out.println(String.format("*********** REGISTERING USER %s ***********", user));
channel.sendResponse(new StringRestResponse(RestStatus.OK, "registered"));
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment