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

JavaSpring.libraries.spring-cloud.apiKeyRequestInterceptor.mustache Maven / Gradle / Ivy

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

}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy