为APIGateway其余客户端实现缓存功能

时间:2018-09-11 06:25:54

标签: rest caching jax-rs aws-api-gateway api-gateway

我向剩余API发出POST请求的方法粘贴在下面。在APIGateWay上启用了缓存。如何在我的帖子请求中添加缓存键?我正在使用jax-rs建立请求。 https://docs.aws.amazon.com/apigateway/latest/developerguide/api-gateway-caching.html#enable-api-gateway-cache-keys

public static Response callWebTarget(WebTarget webTarget, String apiPath, String apiGatewayKey, String payloadJson, Map<String, Object> headerList) {
    Invocation.Builder builder = webTarget
            .path(apiPath)
            .request(MediaType.APPLICATION_JSON)
            .header(API_KEY_HEADER, apiGatewayKey);
    for (Map.Entry<String, Object> headerEntry : headerList.entrySet()) {
        builder.header(headerEntry.getKey(),headerEntry.getValue());
    }
    return builder.post(Entity.json(payloadJson));
}

0 个答案:

没有答案