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)
| 507 | // mapChildNamespaceRoute sets a handler returning a dictionary of resources |
| 508 | // supported by a certain API version identified by the given namespace |
| 509 | func 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 | } |
no test coverage detected