mirror of
https://github.com/foomo/contentserver.git
synced 2025-10-16 12:25:44 +00:00
feat: add PathDataFields option on GetContent
This commit is contained in:
parent
c9bf5666e5
commit
5788fd203d
@ -51,7 +51,7 @@ func (node *RepoNode) InPath(path []*Item) bool {
|
||||
}
|
||||
|
||||
// GetPath get a path for a repo node
|
||||
func (node *RepoNode) GetPath() []*Item {
|
||||
func (node *RepoNode) GetPath(dataFields []string) []*Item {
|
||||
|
||||
var (
|
||||
parentNode = node.parent
|
||||
@ -67,8 +67,13 @@ func (node *RepoNode) GetPath() []*Item {
|
||||
i = 0
|
||||
path = make([]*Item, pathLength)
|
||||
)
|
||||
|
||||
if dataFields == nil {
|
||||
dataFields = []string{}
|
||||
}
|
||||
|
||||
for parentNode != nil {
|
||||
path[i] = parentNode.ToItem([]string{})
|
||||
path[i] = parentNode.ToItem(dataFields)
|
||||
parentNode = parentNode.parent
|
||||
i++
|
||||
}
|
||||
|
||||
@ -13,11 +13,12 @@ import (
|
||||
|
||||
"github.com/foomo/contentserver/status"
|
||||
|
||||
"go.uber.org/zap"
|
||||
|
||||
"github.com/foomo/contentserver/content"
|
||||
"github.com/foomo/contentserver/logger"
|
||||
"github.com/foomo/contentserver/requests"
|
||||
"github.com/foomo/contentserver/responses"
|
||||
"go.uber.org/zap"
|
||||
)
|
||||
|
||||
const maxGetURIForNodeRecursionLevel = 1000
|
||||
@ -199,7 +200,7 @@ func (repo *Repo) GetContent(r *requests.Content) (c *content.SiteContent, err e
|
||||
c.Dimension = resolvedDimension
|
||||
c.URI = resolvedURI
|
||||
c.Item = node.ToItem(r.DataFields)
|
||||
c.Path = node.GetPath()
|
||||
c.Path = node.GetPath(r.PathDataFields)
|
||||
// fetch URIs for all dimensions
|
||||
uris := make(map[string]string)
|
||||
for dimensionName := range repo.Directory {
|
||||
|
||||
@ -36,10 +36,11 @@ type Nodes struct {
|
||||
|
||||
// Content - the standard request to contentserver
|
||||
type Content struct {
|
||||
Env *Env `json:"env"`
|
||||
URI string `json:"URI"`
|
||||
Nodes map[string]*Node `json:"nodes"`
|
||||
DataFields []string `json:"dataFields"`
|
||||
Env *Env `json:"env"`
|
||||
URI string `json:"URI"`
|
||||
Nodes map[string]*Node `json:"nodes"`
|
||||
DataFields []string `json:"dataFields"`
|
||||
PathDataFields []string `json:"pathDataFields"`
|
||||
}
|
||||
|
||||
// Update - request an update
|
||||
|
||||
Loading…
Reference in New Issue
Block a user