Пример #1
0
func TestRestrictedToPathRequest(t *testing.T) {
	prox := goprox.New(destURL, goprox.Options{
		Path: "/proxy",
	})

	res := httptest.NewRecorder()
	req, _ := http.NewRequest("GET", "http://example.com/proxy/foo", nil)

	prox.Handler(testHandler).ServeHTTP(res, req)

	assertHeaders(t, res.Header(), map[string]string{
		"X-Forwarded-For": "foo.com",
	})
}
Пример #2
0
func TestNoConfig(t *testing.T) {
	prox := goprox.New(destURL, goprox.Options{
	// Intentionally left blank.
	})

	res := httptest.NewRecorder()
	req, _ := http.NewRequest("GET", "http://example.com/foo", nil)

	prox.Handler(testHandler).ServeHTTP(res, req)

	assertHeaders(t, res.Header(), map[string]string{
		"X-Forwarded-For": "foo.com",
	})
}