public void put(String key, String value) throws Exception {
String encrypted;
try {
encrypted = encryption.encrypt(value);
} catch (Exception e) {
throw new Exception("Could not encrypt value");
}
HttpRequest request = new HttpRequestWithBody(
HttpMethod.PUT,
makeConsulUrl(key)
).body(encrypted).getHttpRequest();
authorizeHttpRequest(request);
HttpResponse<String> response;
try {
response = HttpClientHelper.request(request, String.class);
} catch (Exception exception) {
throw new ConsulException("Consul request failed", exception);
}
if (!response.getBody().equals("true")) {
throw new ConsulException(
String.format("Consul PUT %s failed", key)
);
}
}
Client.java 文件源码
java
阅读 30
收藏 0
点赞 0
评论 0
项目:gatekeeper
作者:
评论列表
文章目录