JavaSpring.libraries.spring-cloud.apiKeyRequestInterceptor.mustache Maven / Gradle / Ivy
Go to download
Show more of this group Show more artifacts with this name
Show all versions of stackgen Show documentation
Show all versions of stackgen Show documentation
Starter StackGen CORE Service Generator
package {{configPackage}};
import feign.RequestInterceptor;
import feign.RequestTemplate;
import feign.Util;
public class ApiKeyRequestInterceptor implements RequestInterceptor {
private final String location;
private final String name;
private String value;
public ApiKeyRequestInterceptor(String location, String name, String value) {
Util.checkNotNull(location, "location", new Object[0]);
Util.checkNotNull(name, "name", new Object[0]);
Util.checkNotNull(value, "value", new Object[0]);
this.location = location;
this.name = name;
this.value = value;
}
@Override
public void apply(RequestTemplate requestTemplate) {
if(location.equals("header")) {
requestTemplate.header(name, value);
} else if(location.equals("query")) {
requestTemplate.query(name, value);
}
}
}