17119: drop the 'Kind' fields from the structs, autogenerate them instead.
[arvados.git] / lib / controller / router / response.go
index 309ed48f64516be4211b0cd90950f09955fb5aa2..aee2fc590b093a2093ea26ce2cd91060096be198 100644 (file)
@@ -77,13 +77,20 @@ func (rtr *router) sendResponse(w http.ResponseWriter, req *http.Request, resp i
        if included, ok := tmp["included"]; ok && included == nil {
                tmp["included"] = make([]interface{}, 0)
        }
-
        defaultItemKind := ""
        if strings.HasSuffix(respKind, "List") {
                defaultItemKind = strings.TrimSuffix(respKind, "List")
        }
 
-       if items, ok := tmp["items"].([]interface{}); ok {
+       var items, included []interface{}
+       var itemsOK, includedOK bool
+       items, itemsOK = tmp["items"].([]interface{})
+       included, includedOK = tmp["included"].([]interface{})
+       if includedOK && len(included) > 0 {
+               items = append(items, included...)
+       }
+
+       if itemsOK {
                for i, item := range items {
                        // Fill in "kind" by inspecting UUID/PDH if
                        // possible; fall back on assuming each