additional endpoint detail (#36)

This commit is contained in:
Michael Quigley 2022-09-01 14:51:33 -04:00
parent 106b8ba469
commit 2b65166f2a
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
4 changed files with 365 additions and 350 deletions

View File

@ -12,6 +12,7 @@
<style>
body {
margin: 0;
padding: 25;
font-family: 'JetBrains Mono', Consolas, 'Courier New', monospace;
-webkit-font-smoothing: antialiased;
-moz-osx-font-smoothing: grayscale;
@ -58,8 +59,8 @@
}
</style>
</head>
<body>
<div id="root">
<body>
<div id="root">
<div id="banner">
<svg id="ziggy" viewBox="0 0 21.9 37.6" style="width: 200px; height: 343.38px;">
<style type="text/css">
@ -389,11 +390,13 @@
<div id="info">
<h2>{{ .Now }}</h2>
<h3>This Endpoint:</h3>
<h3>At This Endpoint:</h3>
<table>
<tr><td class="td-key">Host Header</td><td>{{ .Host }}</td></tr>
<tr><td class="td-key">Remote Address</td><td>{{ .Remote }}</td></tr>
<tr><td class="td-key">Local IP Addresses</td><td>{{ .Ips }}</td></tr>
<tr><td>Remote Address</td><td>{{ .RemoteAddr }}</td></tr>
<tr><td>This Host</td><td>{{ .Host }}</td></tr>
<tr><td>This Host Detail</td><td>{{ .HostDetail }}</td></tr>
<tr><td>Local IP Addresses</td><td>{{ .Ips }}</td></tr>
<tr><td>Host Header</td><td>{{ .HostHeader }}</td></tr>
</table>
<h3>Extended Headers:</h3>
@ -401,7 +404,7 @@
<tbody>
{{ range $header, $value := .Headers }}
<tr>
<td class="td-key">{{ $header }}</td>
<td>{{ $header }}</td>
<td>
{{ range $v := $value }}
{{ $v }}
@ -413,6 +416,6 @@
</table>
</div>
</div>
</div>
</body>
</div>
</body>
</html>

View File

@ -62,23 +62,35 @@ func (cmd *testEndpointCommand) serveIndex(w http.ResponseWriter, r *http.Reques
type endpointData struct {
Now time.Time
RemoteAddr string
Host string
Headers map[string][]string
Remote string
HostDetail string
Ips string
HostHeader string
Headers map[string][]string
}
func newEndpointData(r *http.Request) *endpointData {
ed := &endpointData{
Now: time.Now(),
Host: r.Host,
HostHeader: r.Host,
Headers: r.Header,
Remote: r.RemoteAddr,
RemoteAddr: r.RemoteAddr,
}
ed.getHostInfo()
ed.getIps()
return ed
}
func (ed *endpointData) getHostInfo() {
host, hostDetail, err := getHost()
if err != nil {
logrus.Errorf("error getting host detail: %v", err)
}
ed.Host = host
ed.HostDetail = hostDetail
}
func (ed *endpointData) getIps() {
addrs, err := net.InterfaceAddrs()
if err == nil {

View File

@ -19,7 +19,7 @@ import (
var Default = NewHTTPClient(nil)
const (
// DefaultHost is the default Host
// DefaultHost is the default HostHeader
// found in Meta (info) section of spec file
DefaultHost string = "localhost"
// DefaultBasePath is the default BasePath

View File

@ -5,7 +5,7 @@
// zrok client access
// Schemes:
// http
// Host: localhost
// HostHeader: localhost
// BasePath: /api/v1
// Version: 1.0.0
//