// enrichLinkTypeList includes related resources in the list's "included" array func enrichLinkTypeList(ctx *workItemLinkContext, list *app.WorkItemLinkTypeList) error { // Add "links" element for _, data := range list.Data { selfURL := rest.AbsoluteURL(ctx.RequestData, ctx.LinkFunc(*data.ID)) data.Links = &app.GenericLinks{ Self: &selfURL, } } // Build our "set" of distinct category IDs already converted as strings categoryIDMap := map[string]bool{} for _, typeData := range list.Data { categoryIDMap[typeData.Relationships.LinkCategory.Data.ID] = true } // Now include the optional link category data in the work item link type "included" array for categoryID := range categoryIDMap { linkCat, err := ctx.Application.WorkItemLinkCategories().Load(ctx.Context, categoryID) if err != nil { jerrors, httpStatusCode := jsonapi.ErrorToJSONAPIErrors(err) return ctx.ResponseData.Service.Send(ctx.Context, httpStatusCode, jerrors) } list.Included = append(list.Included, linkCat.Data) } return nil }