|
|
@@ -271,6 +271,7 @@ import org.elasticsearch.persistent.StartPersistentTaskAction;
|
|
|
import org.elasticsearch.persistent.UpdatePersistentTaskStatusAction;
|
|
|
import org.elasticsearch.plugins.ActionPlugin;
|
|
|
import org.elasticsearch.plugins.ActionPlugin.ActionHandler;
|
|
|
+import org.elasticsearch.plugins.interceptor.RestInterceptorActionPlugin;
|
|
|
import org.elasticsearch.rest.RestController;
|
|
|
import org.elasticsearch.rest.RestHandler;
|
|
|
import org.elasticsearch.rest.RestHeaderDefinition;
|
|
|
@@ -477,24 +478,26 @@ public class ActionModule extends AbstractModule {
|
|
|
new RestHeaderDefinition(Task.X_ELASTIC_PRODUCT_ORIGIN_HTTP_HEADER, false)
|
|
|
)
|
|
|
).collect(Collectors.toSet());
|
|
|
- UnaryOperator<RestHandler> restWrapper = null;
|
|
|
+ UnaryOperator<RestHandler> restInterceptor = null;
|
|
|
for (ActionPlugin plugin : actionPlugins) {
|
|
|
- UnaryOperator<RestHandler> newRestWrapper = plugin.getRestHandlerWrapper(threadPool.getThreadContext());
|
|
|
- if (newRestWrapper != null) {
|
|
|
- logger.debug("Using REST wrapper from plugin " + plugin.getClass().getName());
|
|
|
- if (plugin.getClass().getCanonicalName() == null
|
|
|
- || plugin.getClass().getCanonicalName().startsWith("org.elasticsearch.xpack") == false) {
|
|
|
- throw new IllegalArgumentException(
|
|
|
- "The "
|
|
|
- + plugin.getClass().getName()
|
|
|
- + " plugin tried to install a custom REST "
|
|
|
- + "wrapper. This functionality is not available anymore."
|
|
|
- );
|
|
|
+ if (plugin instanceof RestInterceptorActionPlugin riplugin) {
|
|
|
+ UnaryOperator<RestHandler> newRestInterceptor = riplugin.getRestHandlerInterceptor(threadPool.getThreadContext());
|
|
|
+ if (newRestInterceptor != null) {
|
|
|
+ logger.debug("Using REST interceptor from plugin " + plugin.getClass().getName());
|
|
|
+ if (plugin.getClass().getCanonicalName() == null
|
|
|
+ || plugin.getClass().getCanonicalName().startsWith("org.elasticsearch.xpack") == false) {
|
|
|
+ throw new IllegalArgumentException(
|
|
|
+ "The "
|
|
|
+ + plugin.getClass().getName()
|
|
|
+ + " plugin tried to install a custom REST "
|
|
|
+ + "interceptor. This functionality is not available anymore."
|
|
|
+ );
|
|
|
+ }
|
|
|
+ if (restInterceptor != null) {
|
|
|
+ throw new IllegalArgumentException("Cannot have more than one plugin implementing a REST interceptor");
|
|
|
+ }
|
|
|
+ restInterceptor = newRestInterceptor;
|
|
|
}
|
|
|
- if (restWrapper != null) {
|
|
|
- throw new IllegalArgumentException("Cannot have more than one plugin implementing a REST wrapper");
|
|
|
- }
|
|
|
- restWrapper = newRestWrapper;
|
|
|
}
|
|
|
}
|
|
|
mappingRequestValidators = new RequestValidators<>(
|
|
|
@@ -504,7 +507,7 @@ public class ActionModule extends AbstractModule {
|
|
|
actionPlugins.stream().flatMap(p -> p.indicesAliasesRequestValidators().stream()).toList()
|
|
|
);
|
|
|
|
|
|
- restController = new RestController(headers, restWrapper, nodeClient, circuitBreakerService, usageService);
|
|
|
+ restController = new RestController(headers, restInterceptor, nodeClient, circuitBreakerService, usageService);
|
|
|
}
|
|
|
|
|
|
public Map<String, ActionHandler<?, ?>> getActions() {
|