Skip to content

Commit

Permalink
Return actual empty response. Fixes #262
Browse files Browse the repository at this point in the history
  • Loading branch information
Dragomir-Ivanov authored and smyrman committed Dec 3, 2019
1 parent cb8b8a2 commit 9640d5c
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion rest/response.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ func (f DefaultResponseFormatter) FormatItem(ctx context.Context, headers http.H
if !i.Updated.IsZero() {
headers.Set("Last-Modified", i.Updated.In(time.UTC).Format("Mon, 02 Jan 2006 15:04:05 GMT"))
}
if skipBody {
if skipBody || i.Payload == nil {
return ctx, nil
}
return ctx, i.Payload
Expand Down
4 changes: 2 additions & 2 deletions rest/response_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -78,13 +78,13 @@ func TestDefaultResponseFormatterFormatItem(t *testing.T) {
rctx, payload = rf.FormatItem(ctx, h, &resource.Item{Updated: update}, false)
assert.Equal(t, http.Header{"Last-Modified": []string{"Tue, 23 Feb 2016 02:49:16 GMT"}}, h)
assert.Equal(t, rctx, ctx)
assert.Equal(t, map[string]interface{}(nil), payload)
assert.Equal(t, nil, payload)

h = http.Header{}
rctx, payload = rf.FormatItem(ctx, h, &resource.Item{ETag: "1234"}, false)
assert.Equal(t, http.Header{"Etag": []string{`W/"1234"`}}, h)
assert.Equal(t, rctx, ctx)
assert.Equal(t, map[string]interface{}(nil), payload)
assert.Equal(t, nil, payload)
}

func TestDefaultResponseFormatterFormatList(t *testing.T) {
Expand Down

0 comments on commit 9640d5c

Please sign in to comment.