All Downloads are FREE. Search and download functionalities are using the official Maven repository.

mesosphere.dcos.client.DCOSAPIInterceptor Maven / Gradle / Ivy

There is a newer version: 0.6.3
Show newest version
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);
    }
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy