mirror of https://github.com/mpolden/echoip
Add support for HTTPie. Fixes #13
This commit is contained in:
parent
f4420781a2
commit
5ad48ad3fa
|
@ -18,7 +18,7 @@ import (
|
||||||
|
|
||||||
const APPLICATION_JSON = "application/json"
|
const APPLICATION_JSON = "application/json"
|
||||||
|
|
||||||
var cliUserAgentExp = regexp.MustCompile(`^(?i)((curl|wget|fetch\slibfetch|Go-http-client)\/.*|Go\s1\.1\spackage\shttp)$`)
|
var cliUserAgentExp = regexp.MustCompile(`^((curl|Wget|fetch\slibfetch|Go-http-client|HTTPie)\/.*|Go\s1\.1\spackage\shttp)$`)
|
||||||
|
|
||||||
type API struct {
|
type API struct {
|
||||||
CORS bool
|
CORS bool
|
||||||
|
|
|
@ -132,6 +132,7 @@ func TestCLIMatcher(t *testing.T) {
|
||||||
{"curl/7.26.0", true},
|
{"curl/7.26.0", true},
|
||||||
{"Wget/1.13.4 (linux-gnu)", true},
|
{"Wget/1.13.4 (linux-gnu)", true},
|
||||||
{"fetch libfetch/2.0", true},
|
{"fetch libfetch/2.0", true},
|
||||||
|
{"HTTPie/0.9.3", true},
|
||||||
{browserUserAgent, false},
|
{browserUserAgent, false},
|
||||||
}
|
}
|
||||||
for _, tt := range tests {
|
for _, tt := range tests {
|
||||||
|
|
|
@ -37,7 +37,7 @@
|
||||||
<h1>What is my IP address?</h1>
|
<h1>What is my IP address?</h1>
|
||||||
<p><code class="ip">{{ .IP }}</code></p>
|
<p><code class="ip">{{ .IP }}</code></p>
|
||||||
<p>Multiple command line HTTP clients are supported,
|
<p>Multiple command line HTTP clients are supported,
|
||||||
including <a href="https://curl.haxx.se/">curl</a>, <a href="https://www.gnu.org/software/wget/">GNU
|
including <a href="https://curl.haxx.se/">curl</a>, <a href="https://github.com/jkbrzt/httpie">httpie</a>, <a href="https://www.gnu.org/software/wget/">GNU
|
||||||
Wget</a>
|
Wget</a>
|
||||||
and <a href="https://www.freebsd.org/cgi/man.cgi?fetch(1)">fetch</a>.</p>
|
and <a href="https://www.freebsd.org/cgi/man.cgi?fetch(1)">fetch</a>.</p>
|
||||||
</div>
|
</div>
|
||||||
|
@ -49,6 +49,9 @@
|
||||||
$ curl ifconfig.co
|
$ curl ifconfig.co
|
||||||
{{ .IP }}
|
{{ .IP }}
|
||||||
|
|
||||||
|
$ http ifconfig.co
|
||||||
|
{{ .IP }}
|
||||||
|
|
||||||
$ wget -qO- ifconfig.co
|
$ wget -qO- ifconfig.co
|
||||||
{{ .IP }}
|
{{ .IP }}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue