GetSchemaByPath - gets schema by sync_key_template path
(path string)
| 520 | |
| 521 | //GetSchemaByPath - gets schema by sync_key_template path |
| 522 | func 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 | |
| 536 | func checkIfPathMatchesSyncKeyTemplate(path string, syncKeyTemplate string) bool { |
| 537 | syncKeyTemplateSplit := strings.Split(syncKeyTemplate, "/") |
no test coverage detected