From 6b99b09e0b44d9f520bf9058750988a70db41142 Mon Sep 17 00:00:00 2001 From: Jade McGough Date: Thu, 10 Jan 2019 11:41:17 -0800 Subject: [PATCH] fix(http): add labels to view links responses --- http/view_service.go | 6 ++++-- http/view_test.go | 5 +++++ 2 files changed, 9 insertions(+), 2 deletions(-) diff --git a/http/view_service.go b/http/view_service.go index 9685d3395f..69fffc8288 100644 --- a/http/view_service.go +++ b/http/view_service.go @@ -72,7 +72,8 @@ func NewViewHandler(mappingService platform.UserResourceMappingService, labelSer } type viewLinks struct { - Self string `json:"self"` + Self string `json:"self"` + Labels string `json:"labels"` } type viewResponse struct { @@ -100,7 +101,8 @@ func (r viewResponse) MarshalJSON() ([]byte, error) { func newViewResponse(c *platform.View) viewResponse { return viewResponse{ Links: viewLinks{ - Self: fmt.Sprintf("/api/v2/views/%s", c.ID), + Self: fmt.Sprintf("/api/v2/views/%s", c.ID), + Labels: fmt.Sprintf("/api/v2/views/%s/labels", c.ID), }, View: *c, } diff --git a/http/view_test.go b/http/view_test.go index 078dd64916..ae7f1e99a5 100644 --- a/http/view_test.go +++ b/http/view_test.go @@ -77,6 +77,7 @@ func TestService_handleGetViews(t *testing.T) { "id": "7365637465747572", "name": "hello", "links": { + "labels": "/api/v2/views/7365637465747572/labels", "self": "/api/v2/views/7365637465747572" }, "properties": { @@ -95,6 +96,7 @@ func TestService_handleGetViews(t *testing.T) { "id": "6167697474697320", "name": "example", "links": { + "labels": "/api/v2/views/6167697474697320/labels", "self": "/api/v2/views/6167697474697320" }, "properties": { @@ -210,6 +212,7 @@ func TestService_handleGetView(t *testing.T) { "id": "020f755c3c082000", "name": "example", "links": { + "labels": "/api/v2/views/020f755c3c082000/labels", "self": "/api/v2/views/020f755c3c082000" }, "properties": { @@ -326,6 +329,7 @@ func TestService_handlePostViews(t *testing.T) { "id": "020f755c3c082000", "name": "hello", "links": { + "labels": "/api/v2/views/020f755c3c082000/labels", "self": "/api/v2/views/020f755c3c082000" }, "properties": { @@ -529,6 +533,7 @@ func TestService_handlePatchView(t *testing.T) { "id": "020f755c3c082000", "name": "example", "links": { + "labels": "/api/v2/views/020f755c3c082000/labels", "self": "/api/v2/views/020f755c3c082000" }, "properties": {