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

Function mapChildNamespaceRoute

server/api.go:509–533  ·  view source on GitHub ↗

mapChildNamespaceRoute sets a handler returning a dictionary of resources supported by a certain API version identified by the given namespace

(route martini.Router, namespace *schema.Namespace)

Source from the content-addressed store, hash-verified

507// mapChildNamespaceRoute sets a handler returning a dictionary of resources
508// supported by a certain API version identified by the given namespace
509func mapChildNamespaceRoute(route martini.Router, namespace *schema.Namespace) {
510 log.Debug("[Path] %s", namespace.GetFullPrefix())
511 route.Get(
512 namespace.GetFullPrefix(),
513 func(w http.ResponseWriter, r *http.Request, p martini.Params, context martini.Context) {
514 resources := []schema.NamespaceResource{}
515 for _, s := range schema.GetManager().Schemas() {
516 if s.NamespaceID == namespace.ID {
517 resources = append(resources, schema.NamespaceResource{
518 Links: []schema.Link{
519 {
520 Href: s.GetPluralURL(),
521 Rel: "self",
522 },
523 },
524 Name: s.Singular,
525 Collection: s.Plural,
526 })
527 }
528 }
529
530 routes.ServeJson(w, map[string][]schema.NamespaceResource{"resources": resources})
531 },
532 )
533}

Callers 1

MapNamespacesRoutesFunction · 0.85

Calls 5

GetFullPrefixMethod · 0.80
GetPluralURLMethod · 0.80
DebugMethod · 0.65
GetMethod · 0.65
SchemasMethod · 0.65

Tested by

no test coverage detected