Multiple hosts in one Java Rest Client with different API Keys

Hi, having trouble with implementing Java Rest Client v.7.17 - the requirement is to use multiple hosts with one client. At the same time our elastic uses Api Keys with header "Authorization" to authorize. So my question is: is it somehow possible to set different headers for different hosts? I already tried interceptor - but it gives only relative URI (eg "/book/create") without host on which I should decide what headers set to use (our every host is fully operational and interchangeable)

Found solution. There is interceptor called RequestTargetHost. Host is stored here :

final HttpCoreContext coreContext = HttpCoreContext.adapt(context);
String host = coreContext.getTargetHost().getHostName();
1 Like

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