mirror of
https://github.com/zeromicro/go-zero.git
synced 2025-01-23 17:20:24 +08:00
20 lines
330 B
Go
20 lines
330 B
Go
|
package internal
|
||
|
|
||
|
import (
|
||
|
"net/http"
|
||
|
"strings"
|
||
|
"testing"
|
||
|
|
||
|
"github.com/stretchr/testify/assert"
|
||
|
)
|
||
|
|
||
|
func TestGetRemoteAddr(t *testing.T) {
|
||
|
host := "8.8.8.8"
|
||
|
r, err := http.NewRequest(http.MethodGet, "/", strings.NewReader(""))
|
||
|
assert.Nil(t, err)
|
||
|
|
||
|
r.Header.Set(xForwardFor, host)
|
||
|
assert.Equal(t, host, GetRemoteAddr(r))
|
||
|
}
|
||
|
|