Module org.elasticsearch.server
Interface RestServerActionPlugin
- All Superinterfaces:
ActionPlugin
An action plugin that intercepts incoming the REST requests.
-
Nested Class Summary
Nested classes/interfaces inherited from interface org.elasticsearch.plugins.ActionPlugin
ActionPlugin.ActionHandler<Request extends ActionRequest,
Response extends ActionResponse> -
Method Summary
Modifier and TypeMethodDescriptiondefault RestController
getRestController
(RestInterceptor interceptor, NodeClient client, CircuitBreakerService circuitBreakerService, UsageService usageService, TelemetryProvider telemetryProvider) Returns a replacementRestController
to be used in the server.getRestHandlerInterceptor
(ThreadContext threadContext) Returns a function used to intercept each rest request before handling the request.Methods inherited from interface org.elasticsearch.plugins.ActionPlugin
getActionFilters, getActions, getMappedActionFilters, getRestHandlers, getRestHeaders, getTaskHeaders, indicesAliasesRequestValidators, mappingRequestValidators
-
Method Details
-
getRestHandlerInterceptor
Returns a function used to intercept each rest request before handling the request. The returnedUnaryOperator
is called for every incoming rest request and receives the original rest handler as it's input. This allows adding arbitrary functionality around rest request handlers to do for instance logging or authentication. A simple example of how to only allow GET request is here:UnaryOperator<RestHandler> getRestHandlerInterceptor(ThreadContext threadContext) { return originalHandler -> (RestHandler) (request, channel, client) -> { if (request.method() != Method.GET) { throw new IllegalStateException("only GET requests are allowed"); } originalHandler.handleRequest(request, channel, client); }; }
-
getRestController
@Nullable default RestController getRestController(@Nullable RestInterceptor interceptor, NodeClient client, CircuitBreakerService circuitBreakerService, UsageService usageService, TelemetryProvider telemetryProvider) Returns a replacementRestController
to be used in the server. Note: Only one installed plugin may override the rest controller.
-