@JsonIgnore public Consul build() { final Consul.Builder builder = Consul.builder().withHostAndPort(endpoint).withPing(servicePing); aclToken.ifPresent( token -> { // setting both acl token here and with header, supplying an auth // header. This should cover both use cases: endpoint supports // legacy ?token query param and other case in which endpoint // requires an X-Consul-Token header. // @see https://www.consul.io/api/index.html#acls builder.withAclToken(token).withHeaders(ImmutableMap.of(CONSUL_AUTH_HEADER_KEY, token)); }); return builder.build(); }
.withHeaders(ImmutableMap.of(CONSUL_AUTH_HEADER_KEY, token)); });