From b45431cd01bbe007ffbe8db6177b7ea4132eebd2 Mon Sep 17 00:00:00 2001 From: Pijus Kamandulis Date: Wed, 14 Feb 2024 20:14:10 +0200 Subject: [PATCH] Partition Key Ranges compatibility fix --- api/handlers/partition_key_ranges.go | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/api/handlers/partition_key_ranges.go b/api/handlers/partition_key_ranges.go index cd186eb..1e03921 100644 --- a/api/handlers/partition_key_ranges.go +++ b/api/handlers/partition_key_ranges.go @@ -1,6 +1,7 @@ package handlers import ( + "fmt" "net/http" "github.com/gin-gonic/gin" @@ -12,8 +13,19 @@ func GetPartitionKeyRanges(c *gin.Context) { databaseId := c.Param("databaseId") collectionId := c.Param("collId") + if c.Request.Header.Get("if-none-match") != "" { + c.AbortWithStatus(http.StatusNotModified) + return + } + partitionKeyRanges, status := repositories.GetPartitionKeyRanges(databaseId, collectionId) if status == repositorymodels.StatusOk { + c.Header("etag", "\"420\"") + c.Header("lsn", "420") + c.Header("x-ms-cosmos-llsn", "420") + c.Header("x-ms-global-committed-lsn", "420") + c.Header("x-ms-item-count", fmt.Sprintf("%d", len(partitionKeyRanges))) + c.IndentedJSON(http.StatusOK, gin.H{ "_rid": "", "_count": len(partitionKeyRanges),