Send plain response for Accept: text/plain

Fixes #24
This commit is contained in:
Martin Polden
2016-11-16 20:00:03 +01:00
parent 4a9710dcea
commit faf2f62612
2 changed files with 21 additions and 15 deletions

View File

@ -19,7 +19,10 @@ import (
"github.com/gorilla/mux"
)
const jsonMediaType = "application/json"
const (
jsonMediaType = "application/json"
textMediaType = "text/plain"
)
var userAgentPattern = regexp.MustCompile(
`^(?:curl|Wget|fetch\slibfetch|ddclient|Go-http-client|HTTPie)\/.*|Go\s1\.1\spackage\shttp$`,
@ -243,6 +246,7 @@ func (a *API) Router() http.Handler {
// CLI
r.Handle("/", appHandler(a.CLIHandler)).Methods("GET").MatcherFunc(cliMatcher)
r.Handle("/", appHandler(a.CLIHandler)).Methods("GET").Headers("Accept", textMediaType)
r.Handle("/ip", appHandler(a.CLIHandler)).Methods("GET")
r.Handle("/country", appHandler(a.CLICountryHandler)).Methods("GET")
r.Handle("/city", appHandler(a.CLICityHandler)).Methods("GET")