Client.java 文件源码

java
阅读 30 收藏 0 点赞 0 评论 0

项目:gatekeeper 作者:
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)
        );
    }
}
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号