From 75ce16b63344d2ffc51d64a973f5690b058bb9ec Mon Sep 17 00:00:00 2001 From: zhulongcheng Date: Thu, 13 Dec 2018 00:01:16 +0800 Subject: [PATCH] make prev/next links omitempty --- http/bucket_test.go | 6 +----- paging.go | 4 ++-- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/http/bucket_test.go b/http/bucket_test.go index 8aa68f33ff..41f9b39c22 100644 --- a/http/bucket_test.go +++ b/http/bucket_test.go @@ -70,7 +70,6 @@ func TestService_handleGetBuckets(t *testing.T) { body: ` { "links": { - "prev": "", "self": "/api/v2/buckets?descending=false&limit=1&offset=0", "next": "/api/v2/buckets?descending=false&limit=1&offset=1" }, @@ -122,9 +121,7 @@ func TestService_handleGetBuckets(t *testing.T) { body: ` { "links": { - "prev": "", - "self": "/api/v2/buckets?descending=false&limit=1&offset=0", - "next": "" + "self": "/api/v2/buckets?descending=false&limit=1&offset=0" }, "buckets": [] }`, @@ -166,7 +163,6 @@ func TestService_handleGetBuckets(t *testing.T) { if eq, _ := jsonEqual(string(body), tt.wants.body); tt.wants.body != "" && !eq { t.Errorf("%q. handleGetBuckets() = \n***%v***\n,\nwant\n***%v***", tt.name, string(body), tt.wants.body) } - }) } } diff --git a/paging.go b/paging.go index f3bfa3d755..b024c18c11 100644 --- a/paging.go +++ b/paging.go @@ -17,9 +17,9 @@ type PagingFilter interface { // PagingLinks represents paging links. type PagingLinks struct { - Prev string `json:"prev"` + Prev string `json:"prev,omitempty"` Self string `json:"self"` - Next string `json:"next"` + Next string `json:"next,omitempty"` } // FindOptions represents options passed to all find methods with multiple results.