mirror of
https://github.com/mpolden/echoip.git
synced 2024-11-10 07:27:22 +01:00
Add /json route
This commit is contained in:
parent
26fdb23f37
commit
7d23fe9853
@ -277,6 +277,7 @@ func (a *API) Handlers() http.Handler {
|
||||
|
||||
// JSON
|
||||
r.Handle("/", appHandler(a.JSONHandler)).Methods("GET").Headers("Accept", APPLICATION_JSON)
|
||||
r.Handle("/json", appHandler(a.JSONHandler)).Methods("GET")
|
||||
|
||||
// CLI
|
||||
r.Handle("/", appHandler(a.CLIHandler)).Methods("GET").MatcherFunc(cliMatcher)
|
||||
|
@ -71,7 +71,7 @@ $ http ifconfig.co/country
|
||||
<div class="pure-u-1 pure-u-md-1-2">
|
||||
<p>JSON output:</p>
|
||||
<pre>
|
||||
$ http --json ifconfig.co
|
||||
$ http ifconfig.co/json
|
||||
HTTP/1.1 200 OK
|
||||
Content-Length: 61
|
||||
Content-Type: application/json
|
||||
@ -82,6 +82,9 @@ Date: Fri, 15 Apr 2016 17:26:53 GMT
|
||||
"hostname": "{{ .Hostname }}",{{ end }}
|
||||
"ip": "{{ .IP }}"
|
||||
}
|
||||
|
||||
# or set Accept header to application/json:
|
||||
# http --json ifconfig.co
|
||||
</pre>
|
||||
{{ if .PortTesting }}
|
||||
<p>Testing port connectivity (only supports JSON output):</p>
|
||||
|
Loading…
Reference in New Issue
Block a user