mirror of
https://github.com/mpolden/echoip.git
synced 2024-11-10 07:27:22 +01:00
api: handle net/http as cli request
This commit is contained in:
parent
16cbfb2504
commit
5cd09f5e9b
@ -26,7 +26,7 @@ const (
|
||||
APPLICATION_JSON = "application/json"
|
||||
)
|
||||
|
||||
var cliUserAgentExp = regexp.MustCompile("^(?i)(curl|wget|fetch\\slibfetch)\\/.*$")
|
||||
var cliUserAgentExp = regexp.MustCompile(`^(?i)((curl|wget|fetch\slibfetch|Go-http-client)\/.*|Go\s1\.1\spackage\shttp)$`)
|
||||
|
||||
type API struct {
|
||||
CORS bool
|
||||
|
@ -70,6 +70,9 @@ func TestGetIP(t *testing.T) {
|
||||
{s.URL, false, "127.0.0.1\n", "curl/7.26.0", 200},
|
||||
{s.URL, false, "127.0.0.1\n", "Wget/1.13.4 (linux-gnu)", 200},
|
||||
{s.URL, false, "127.0.0.1\n", "fetch libfetch/2.0", 200},
|
||||
{s.URL, false, "127.0.0.1\n", "Go 1.1 package http", 200},
|
||||
{s.URL, false, "127.0.0.1\n", "Go-http-client/1.1", 200},
|
||||
{s.URL, false, "127.0.0.1\n", "Go-http-client/2.0", 200},
|
||||
{s.URL + "/x-ifconfig-ip.json", false, toJSON("x-ifconfig-ip", "127.0.0.1"), "", 200},
|
||||
{s.URL, true, toJSON("x-ifconfig-ip", "127.0.0.1"), "", 200},
|
||||
{s.URL + "/foo", false, "no value found for: foo", "curl/7.26.0", 404},
|
||||
|
Loading…
Reference in New Issue
Block a user