mirror of
https://github.com/mpolden/echoip.git
synced 2025-02-05 06:45:06 +01:00
Use request defined host in index template
This commit is contained in:
parent
7145e0464f
commit
20f3685d06
@ -187,9 +187,10 @@ func (a *API) DefaultHandler(w http.ResponseWriter, r *http.Request) *appError {
|
|||||||
return internalServerError(err)
|
return internalServerError(err)
|
||||||
}
|
}
|
||||||
var data = struct {
|
var data = struct {
|
||||||
|
Host string
|
||||||
Response
|
Response
|
||||||
Oracle
|
Oracle
|
||||||
}{response, a.oracle}
|
}{r.Host, response, a.oracle}
|
||||||
if err := t.Execute(w, &data); err != nil {
|
if err := t.Execute(w, &data); err != nil {
|
||||||
return internalServerError(err)
|
return internalServerError(err)
|
||||||
}
|
}
|
||||||
|
22
index.html
22
index.html
@ -2,7 +2,7 @@
|
|||||||
<html lang="en">
|
<html lang="en">
|
||||||
<head>
|
<head>
|
||||||
<meta charset="utf-8">
|
<meta charset="utf-8">
|
||||||
<title>What is my IP address? — ifconfig.co</title>
|
<title>What is my IP address? — {{ .Host }}</title>
|
||||||
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
<meta name="viewport" content="width=device-width, initial-scale=1.0">
|
||||||
<meta name="description" content="What is my IP address?">
|
<meta name="description" content="What is my IP address?">
|
||||||
<link href="//fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
|
<link href="//fonts.googleapis.com/css?family=Open+Sans" rel="stylesheet">
|
||||||
@ -44,37 +44,37 @@
|
|||||||
<div class="pure-u-1 pure-u-md-1-2">
|
<div class="pure-u-1 pure-u-md-1-2">
|
||||||
<h2>CLI examples:</h2>
|
<h2>CLI examples:</h2>
|
||||||
<pre>
|
<pre>
|
||||||
$ curl ifconfig.co
|
$ curl {{ .Host }}
|
||||||
{{ .IP }}
|
{{ .IP }}
|
||||||
|
|
||||||
$ http -b ifconfig.co
|
$ http -b {{ .Host }}
|
||||||
{{ .IP }}
|
{{ .IP }}
|
||||||
|
|
||||||
$ wget -qO- ifconfig.co
|
$ wget -qO- {{ .Host }}
|
||||||
{{ .IP }}
|
{{ .IP }}
|
||||||
|
|
||||||
$ fetch -qo- https://ifconfig.co
|
$ fetch -qo- https://{{ .Host }}
|
||||||
{{ .IP }}
|
{{ .IP }}
|
||||||
|
|
||||||
$ bat -print=b ifconfig.co/ip
|
$ bat -print=b {{ .Host }}/ip
|
||||||
{{ .IP }}</pre>
|
{{ .IP }}</pre>
|
||||||
{{ if .IsLookupCountryEnabled }}
|
{{ if .IsLookupCountryEnabled }}
|
||||||
<h2>Country lookup:</h2>
|
<h2>Country lookup:</h2>
|
||||||
<pre>
|
<pre>
|
||||||
$ http ifconfig.co/country
|
$ http {{ .Host }}/country
|
||||||
{{ .Country }}</pre>
|
{{ .Country }}</pre>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
{{ if .IsLookupCityEnabled }}
|
{{ if .IsLookupCityEnabled }}
|
||||||
<h2>City lookup:</h2>
|
<h2>City lookup:</h2>
|
||||||
<pre>
|
<pre>
|
||||||
$ http ifconfig.co/city
|
$ http {{ .Host }}/city
|
||||||
{{ .City }}</pre>
|
{{ .City }}</pre>
|
||||||
{{ end }}
|
{{ end }}
|
||||||
</div>
|
</div>
|
||||||
<div class="pure-u-1 pure-u-md-1-2">
|
<div class="pure-u-1 pure-u-md-1-2">
|
||||||
<h2>JSON output:</h2>
|
<h2>JSON output:</h2>
|
||||||
<pre>
|
<pre>
|
||||||
$ http ifconfig.co/json
|
$ http {{ .Host }}/json
|
||||||
{ {{ if .IsLookupCityEnabled }}
|
{ {{ if .IsLookupCityEnabled }}
|
||||||
"city": "{{ .City }}",{{ end }}{{ if .IsLookupCountryEnabled }}
|
"city": "{{ .City }}",{{ end }}{{ if .IsLookupCountryEnabled }}
|
||||||
"country": "{{ .Country }}",{{ end }}{{ if .IsLookupAddrEnabled }}
|
"country": "{{ .Country }}",{{ end }}{{ if .IsLookupAddrEnabled }}
|
||||||
@ -87,12 +87,12 @@ $ http ifconfig.co/json
|
|||||||
<h2>Plain output:</h2>
|
<h2>Plain output:</h2>
|
||||||
<p>Always returns the IP address including a trailing newline, regardless of user agent.</p>
|
<p>Always returns the IP address including a trailing newline, regardless of user agent.</p>
|
||||||
<pre>
|
<pre>
|
||||||
$ http ifconfig.co/ip
|
$ http {{ .Host }}/ip
|
||||||
{{ .IP }}</pre>
|
{{ .IP }}</pre>
|
||||||
{{ if .IsLookupPortEnabled }}
|
{{ if .IsLookupPortEnabled }}
|
||||||
<h2>Testing port connectivity:</h2>
|
<h2>Testing port connectivity:</h2>
|
||||||
<pre>
|
<pre>
|
||||||
$ http ifconfig.co/port/8080
|
$ http {{ .Host }}/port/8080
|
||||||
{
|
{
|
||||||
"ip": "{{ .IP }}",
|
"ip": "{{ .IP }}",
|
||||||
"port": 8080,
|
"port": 8080,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user