use of com.hotels.styx.api.plugins.spi.PluginFactory in project styx by ExpediaGroup.
the class PluginLoadingForStartup method loadPluginFactory.
private static ConfiguredPluginFactory loadPluginFactory(Pair<String, SpiExtension> pair) {
String pluginName = pair.key();
SpiExtension spiExtension = pair.value();
PluginFactory factory = new FileSystemPluginFactoryLoader().load(spiExtension);
return new ConfiguredPluginFactory(pluginName, factory, spiExtension::config);
}
use of com.hotels.styx.api.plugins.spi.PluginFactory in project styx by ExpediaGroup.
the class StyxServerTest method executesPluginsWhenProxying.
@Test
public void executesPluginsWhenProxying() {
Plugin responseDecorator = (request, chain) -> chain.proceed(request).map(response -> response.newBuilder().header("plugin-executed", "yes").build());
PluginFactory pluginFactory = environment -> responseDecorator;
styxServer = new StyxServer.Builder().addRoute("/", originServer1.port()).addPluginFactory("response-decorator", pluginFactory, null).start();
HttpResponse response = await(client.sendRequest(get(format("http://localhost:%d/foo", styxServer.proxyHttpPort())).build()));
assertThat(response.status(), is(OK));
assertThat(response.header("origin"), isValue("first"));
assertThat(response.header("plugin-executed"), isValue("yes"));
configureFor(originServer1.port());
WireMock.verify(getRequestedFor(urlPathEqualTo("/foo")));
}
use of com.hotels.styx.api.plugins.spi.PluginFactory in project styx by ExpediaGroup.
the class FileSystemPluginFactoryLoaderTest method pluginLoaderLoadsPluginFromJarFile.
@Test
public void pluginLoaderLoadsPluginFromJarFile() {
SpiExtensionFactory factory = new SpiExtensionFactory("testgrp.TestPluginModule", pluginsPath.toString());
PluginFactory plugin = pluginFactoryLoader.load(new SpiExtension(factory, config, null));
assertThat(plugin, is(not(nullValue())));
assertThat(plugin.getClass().getName(), is("testgrp.TestPluginModule"));
}
Aggregations