diff --git a/api/api.go b/api/api.go index a354b62..3970581 100644 --- a/api/api.go +++ b/api/api.go @@ -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) diff --git a/index.html b/index.html index a9c1c94..ffd7e67 100644 --- a/index.html +++ b/index.html @@ -71,7 +71,7 @@ $ http ifconfig.co/country
JSON output:
-$ http --json ifconfig.co +$ http ifconfig.co/json HTTP/1.1 200 OK Content-Length: 61 Content-Type: application/json @@ -81,7 +81,10 @@ Date: Fri, 15 Apr 2016 17:26:53 GMT "country": "{{ .Country }}",{{ end }}{{ if .ReverseLookup }} "hostname": "{{ .Hostname }}",{{ end }} "ip": "{{ .IP }}" -} +} + +# or set Accept header to application/json: +# http --json ifconfig.co{{ if .PortTesting }}
Testing port connectivity (only supports JSON output):