You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
19 lines
326 B
Go
19 lines
326 B
Go
4 years ago
|
package httpx
|
||
4 years ago
|
|
||
|
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))
|
||
|
}
|