mesosphere.dcos.client.DCOSAPIInterceptor Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of marathon-client Show documentation
Show all versions of marathon-client Show documentation
A Java API client for Mesosphere's Marathon.
package mesosphere.dcos.client;
import java.util.Collection;
import feign.RequestInterceptor;
import feign.RequestTemplate;
import mesosphere.client.common.HeaderUtils;
public class DCOSAPIInterceptor implements RequestInterceptor {
@Override
public void apply(RequestTemplate template) {
Collection apiSources = template.headers().get(HeaderUtils.API_SOURCE_HEADER);
if (apiSources == null || apiSources.isEmpty()) {
return;
}
if (apiSources.iterator().next().equals(HeaderUtils.MARATHON_API_SOURCE)) {
template.insert(0, "/marathon");
} else if (apiSources.iterator().next().equals(HeaderUtils.METRONOME_API_SOURCE)) {
template.insert(0, "/service/metronome");
}
template.header(HeaderUtils.API_SOURCE_HEADER);
}
}