go-zero/gateway/headerbuilder_test.go
Kevin Wan 13477238a3
feat: restful -> grpc gateway (#2155)
* Revert "chore: remove unimplemented gateway (#2139)"

This reverts commit d70e73ec66.

* feat: working gateway

* feat: use mr to make it faster

* feat: working gateway

* chore: add comments

* feat: support protoset besides reflection

* feat: support zrpc client conf

* docs: update readme

* feat: support grpc-metadata- header to gateway- header conversion

* chore: add docs
2022-07-16 14:11:34 +08:00

22 lines
524 B
Go

package gateway
import (
"net/http/httptest"
"testing"
"github.com/stretchr/testify/assert"
)
func TestBuildHeadersNoValue(t *testing.T) {
req := httptest.NewRequest("GET", "/", nil)
req.Header.Add("a", "b")
assert.Nil(t, buildHeaders(req.Header))
}
func TestBuildHeadersWithValues(t *testing.T) {
req := httptest.NewRequest("GET", "/", nil)
req.Header.Add("grpc-metadata-a", "b")
req.Header.Add("grpc-metadata-b", "b")
assert.EqualValues(t, []string{"gateway-A:b", "gateway-B:b"}, buildHeaders(req.Header))
}