feat: support customized header to metadata processor (#2162)
* chore: add more tests * feat: support customized header processor
This commit is contained in:
21
gateway/internal/headerprocessor_test.go
Normal file
21
gateway/internal/headerprocessor_test.go
Normal file
@@ -0,0 +1,21 @@
|
||||
package internal
|
||||
|
||||
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, ProcessHeaders(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.ElementsMatch(t, []string{"gateway-A:b", "gateway-B:b"}, ProcessHeaders(req.Header))
|
||||
}
|
||||
Reference in New Issue
Block a user