refactor: move json related header vars to internal (#1840)

* refactor: move json related header vars to internal

* refactor: use header.ContentType
This commit is contained in:
Kevin Wan
2022-04-28 15:12:04 +08:00
committed by GitHub
parent cef83efd4e
commit 3bbc90ec24
14 changed files with 58 additions and 42 deletions

View File

@@ -7,6 +7,7 @@ import (
"testing"
"github.com/stretchr/testify/assert"
"github.com/zeromicro/go-zero/rest/internal/header"
)
func TestNamedService_DoRequest(t *testing.T) {
@@ -43,7 +44,7 @@ func TestNamedService_DoRequestPost(t *testing.T) {
service := NewService("foo")
req, err := http.NewRequest(http.MethodPost, svr.URL, nil)
assert.Nil(t, err)
req.Header.Set("Content-Type", "application/json")
req.Header.Set(header.ContentType, header.JsonContentType)
resp, err := service.DoRequest(req)
assert.Nil(t, err)
assert.Equal(t, http.StatusNotFound, resp.StatusCode)