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

Function GetSchemaByPath

schema/schema.go:522–534  ·  view source on GitHub ↗

GetSchemaByPath - gets schema by sync_key_template path

(path string)

Source from the content-addressed store, hash-verified

520
521//GetSchemaByPath - gets schema by sync_key_template path
522func GetSchemaByPath(path string) *Schema {
523 for _, schema := range GetManager().Schemas() {
524 syncKeyTemplate, ok := schema.SyncKeyTemplate()
525 if ok {
526 if checkIfPathMatchesSyncKeyTemplate(path, syncKeyTemplate) {
527 return schema
528 }
529 } else if strings.HasPrefix(path, schema.URL) {
530 return schema
531 }
532 }
533 return nil
534}
535
536func checkIfPathMatchesSyncKeyTemplate(path string, syncKeyTemplate string) bool {
537 syncKeyTemplateSplit := strings.Split(syncKeyTemplate, "/")

Callers 1

schema_test.goFile · 0.85

Calls 4

SyncKeyTemplateMethod · 0.80
GetManagerFunction · 0.70
SchemasMethod · 0.65

Tested by

no test coverage detected