MCPcopy Create free account
hub / github.com/cloudwan/gohan / GenerateCustomPath

Method GenerateCustomPath

schema/schema.go:475–487  ·  view source on GitHub ↗

GenerateCustomPath - returns custom path based on sync_key_template

(data map[string]interface{})

Source from the content-addressed store, hash-verified

473
474//GenerateCustomPath - returns custom path based on sync_key_template
475func (schema *Schema) GenerateCustomPath(data map[string]interface{}) (path string, err error) {
476 syncKeyTemplate, ok := schema.SyncKeyTemplate()
477 if !ok {
478 err = fmt.Errorf("Failed to read sync_key_template from schema %v", schema.URL)
479 return
480 }
481 tpl, err := pongo2.FromString(syncKeyTemplate)
482 if err != nil {
483 return
484 }
485 path, err = tpl.Execute(pongo2.Context{}.Update(data))
486 return
487}
488
489//GetResourceIDFromPath - parse path and gets resourceID from it
490func (schema *Schema) GetResourceIDFromPath(schemaPath string) string {

Callers 3

syncEventMethod · 0.80
generatePathFunction · 0.80
schema_test.goFile · 0.80

Calls 3

SyncKeyTemplateMethod · 0.95
ErrorfMethod · 0.65
UpdateMethod · 0.65

Tested by

no test coverage detected