繁体   English   中英

Azure API 管理 - 操作的 Etag

[英]Azure API Management - Etag for an operation

我们是新来的 Azure API 管理。 我们正在缓存 Dataverse 主实体 web api 调用,并查看如何在 Azure API 管理中添加 ETag 作为响应标头的一部分(后端调用也没有此 header)。 我们如何在操作级别检索它? 是否有可用的参考文档。 抱歉找不到任何。 提前致谢

我们正在缓存 Dataverse 主实体 web api 调用,并查看如何在 Azure API 管理中添加 ETag 作为响应标头的一部分(后端调用也没有此 header)。 我们如何在操作级别检索它?

  1. 获取由其标识符指定的后端的实体 state (Etag) 版本。
HEAD https://management.azure.com/subscriptions/{subscriptionId}/resourceGroups/{resourceGroupName}/providers/Microsoft.ApiManagement/service/{serviceName}/backends/{backendId}?api-version=2021-04-01-preview
  1. Web API 实施
public class OrdersController : ApiController
{
    ...
    public IHttpActionResult FindOrderByID(int id)
    {
        // Find the matching order
        Order order = ...;
        ...

        var hashedOrder = order.GetHashCode();
        string hashedOrderEtag = $"\"{hashedOrder}\"";
        var eTag = new EntityTagHeaderValue(hashedOrderEtag);

        // Return a response message containing the order and the cache control header
        OkResultWithCaching<Order> response = new OkResultWithCaching<Order>(order, this)
        {
            ...,
            ETag = eTag
        };
        return response;
    }
    ...
}

可以参考后端-获取实体标签Azure搜索是否提供Etags用于管理并发添加、更新或删除文档? 什么是 ETag 以及人们为什么使用它

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM