Generate more realistic resource ids

This commit is contained in:
Pijus Kamandulis
2025-02-09 00:36:35 +02:00
parent 787cdb33cf
commit 5d99b653cc
10 changed files with 84 additions and 20 deletions

View File

@@ -75,8 +75,7 @@ func requestToResourceId(c *gin.Context) string {
isFeed := c.Request.Header.Get("A-Im") == "Incremental Feed"
if resourceType == "pkranges" && isFeed {
// CosmosSDK replaces '/' with '-' in resource id requests
resourceId = strings.Replace(collId, "-", "/", -1)
resourceId = collId
}
return resourceId

View File

@@ -6,6 +6,7 @@ import (
"github.com/gin-gonic/gin"
repositorymodels "github.com/pikami/cosmium/internal/repository_models"
"github.com/pikami/cosmium/internal/resourceid"
)
func (h *Handlers) GetPartitionKeyRanges(c *gin.Context) {
@@ -31,8 +32,9 @@ func (h *Handlers) GetPartitionKeyRanges(c *gin.Context) {
collectionRid = collection.ResourceID
}
rid := resourceid.NewCombined(collectionRid, resourceid.New(resourceid.ResourceTypePartitionKeyRange))
c.IndentedJSON(http.StatusOK, gin.H{
"_rid": collectionRid,
"_rid": rid,
"_count": len(partitionKeyRanges),
"PartitionKeyRanges": partitionKeyRanges,
})