use of com.wavefront.agent.channel.GZIPEncodingInterceptorWithVariableCompression in project java by wavefrontHQ.
the class APIContainer method createProviderFactory.
private ResteasyProviderFactory createProviderFactory() {
ResteasyProviderFactory factory = new LocalResteasyProviderFactory(ResteasyProviderFactory.getInstance());
factory.registerProvider(JsonNodeWriter.class);
if (!factory.getClasses().contains(ResteasyJackson2Provider.class)) {
factory.registerProvider(ResteasyJackson2Provider.class);
}
factory.register(GZIPDecodingInterceptor.class);
if (proxyConfig.isGzipCompression()) {
WriterInterceptor interceptor = new GZIPEncodingInterceptorWithVariableCompression(proxyConfig.getGzipCompressionLevel());
factory.register(interceptor);
} else {
factory.register(DisableGZIPEncodingInterceptor.class);
}
factory.register(AcceptEncodingGZIPFilter.class);
// add authorization header for all proxy endpoints, except for /checkin - since it's also
// passed as a parameter, it's creating duplicate headers that cause the entire request to be
// rejected by nginx. unfortunately, RESTeasy is not smart enough to handle that automatically.
factory.register((ClientRequestFilter) context -> {
if ((context.getUri().getPath().contains("/v2/wfproxy") || context.getUri().getPath().contains("/v2/source") || context.getUri().getPath().contains("/event")) && !context.getUri().getPath().endsWith("checkin")) {
context.getHeaders().add("Authorization", "Bearer " + proxyConfig.getToken());
}
});
return factory;
}
Aggregations