mirror of https://github.com/mpolden/echoip
Implement ISO lookup and Map display
This commit is contained in:
parent
1b08803fa9
commit
bd6946b470
|
@ -32,6 +32,9 @@ Country and city lookup:
|
|||
$ http ifconfig.co/country
|
||||
Elbonia
|
||||
|
||||
$ http ifconfig.co/iso
|
||||
EB
|
||||
|
||||
$ http ifconfig.co/city
|
||||
Bornyasherk
|
||||
```
|
||||
|
@ -43,6 +46,7 @@ $ http --json ifconfig.co
|
|||
{
|
||||
"city": "Bornyasherk",
|
||||
"country": "Elbonia",
|
||||
"iso": "EB",
|
||||
"ip": "127.0.0.1",
|
||||
"ip_decimal": 2130706433
|
||||
}
|
||||
|
|
10
api/api.go
10
api/api.go
|
@ -146,6 +146,15 @@ func (a *API) CLICountryHandler(w http.ResponseWriter, r *http.Request) *appErro
|
|||
return nil
|
||||
}
|
||||
|
||||
func (a *API) CLICountryISOHandler(w http.ResponseWriter, r *http.Request) *appError {
|
||||
response, err := a.newResponse(r)
|
||||
if err != nil {
|
||||
return internalServerError(err)
|
||||
}
|
||||
fmt.Fprintln(w, response.CountryISO)
|
||||
return nil
|
||||
}
|
||||
|
||||
func (a *API) CLICityHandler(w http.ResponseWriter, r *http.Request) *appError {
|
||||
response, err := a.newResponse(r)
|
||||
if err != nil {
|
||||
|
@ -256,6 +265,7 @@ func (a *API) Router() http.Handler {
|
|||
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("/iso", appHandler(a.CLICountryISOHandler)).Methods("GET")
|
||||
r.Handle("/city", appHandler(a.CLICityHandler)).Methods("GET")
|
||||
|
||||
// Browser
|
||||
|
|
|
@ -63,6 +63,10 @@ $ bat -print=b {{ .Host }}/ip
|
|||
<pre>
|
||||
$ http {{ .Host }}/country
|
||||
{{ .Country }}</pre>
|
||||
<h2>Country ISO lookup:</h2>
|
||||
<pre>
|
||||
$ http {{ .Host }}/iso
|
||||
{{ .CountryISO }}</pre>
|
||||
{{ end }}
|
||||
{{ if .IsLookupCityEnabled }}
|
||||
<h2>City lookup:</h2>
|
||||
|
|
Loading…
Reference in New Issue