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

Function generatePath

server/sync_writer.go:252–273  ·  view source on GitHub ↗
(resourcePath string, body string)

Source from the content-addressed store, hash-verified

250}
251
252func generatePath(resourcePath string, body string) string {
253 var curSchema = schema.GetSchemaByURLPath(resourcePath)
254 path := resourcePath
255 if _, ok := curSchema.SyncKeyTemplate(); ok {
256 var data map[string]interface{}
257 err := json.Unmarshal(([]byte)(body), &data)
258 if err != nil {
259 log.Error(fmt.Sprintf("Error %v during unmarshaling data %v", err, data))
260 } else {
261 path, err = curSchema.GenerateCustomPath(data)
262 if err != nil {
263 path = resourcePath
264 log.Error(fmt.Sprintf("%v", err))
265 }
266 }
267 }
268 if !curSchema.SkipConfigPrefix() {
269 path = configPrefix + path
270 }
271 log.Info("Generated path: %s", path)
272 return path
273}

Callers 1

syncEventMethod · 0.85

Calls 5

SyncKeyTemplateMethod · 0.80
GenerateCustomPathMethod · 0.80
SkipConfigPrefixMethod · 0.80
ErrorMethod · 0.65
InfoMethod · 0.65

Tested by

no test coverage detected