io.quarkus.eureka.operation.AbstractOperation Maven / Gradle / Ivy
/*
* Copyright 2020 the original author or authors.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package io.quarkus.eureka.operation;
import javax.ws.rs.client.Client;
import javax.ws.rs.client.Invocation.Builder;
import javax.ws.rs.core.MediaType;
import io.quarkus.eureka.config.Location;
public abstract class AbstractOperation implements Operation {
protected Builder restClientBuilder(final Client client, final Location location, final String path) {
Builder builder = client.target(String.join("/", location.getUrl(), path))
.request(MediaType.APPLICATION_JSON_TYPE);
setAuthHeaderIfNessary(builder, location);
return builder;
}
private void setAuthHeaderIfNessary(Builder builder, Location location) {
if (location.hasBasicAuthToken()) {
builder.header("Authorization", "Basic " + location.getBasicAuthToken());
}
}
}
© 2015 - 2025 Weber Informatics LLC | Privacy Policy