Injecting RestController through the RestHandler


(Arul Narasimhan) #1

I have the following code in one of my plugins which works well with ES 5.1.2. However with ES 5.6.8 it compiles, but runs into problem as it is not possible to inject RestController directly.
Please let me know the workaround for the same?
Also could you please share any example?

public class IndexCleanerAction implements RestHandler {
@Inject
public IndexCleanerAction(final RestController controller) {
controller.registerHandler(RestRequest.Method.GET, "/_indexcleaner/indexcleanup", this);
controller.registerHandler(RestRequest.Method.POST, "/_indexcleaner/indexcleanup", this);
controller.registerHandler(RestRequest.Method.PUT, "/_indexcleaner/indexcleanup/{id}", this);
controller.registerHandler(RestRequest.Method.DELETE, "/_indexcleaner/indexcleanup/{id}", this);
}


(Ryan Ernst) #2

Your plugin needs to implement ActionPlugin, and construct your rest handlers and return them from getRestHandlers, which takes the RestController as an argument.


(system) #3

This topic was automatically closed 28 days after the last reply. New replies are no longer allowed.