richer test endpoint (#36)

This commit is contained in:
Michael Quigley 2022-08-30 09:41:32 -04:00
parent 5e4eee670f
commit 65284d696a
No known key found for this signature in database
GPG Key ID: 9B60314A9DD20A62
2 changed files with 11 additions and 3 deletions

View File

@ -47,6 +47,8 @@
</div>
<div id="info">
<h2>The Current Now is {{ .Now }}</h2>
<p>The current <code>HOST</code> header: {{ .Host }}</p>
<p>The remote host making the request: {{ .Remote }}</p>
<p>This host has these IP addresses: {{ .Ips }}</p>
</div>
</div>

View File

@ -4,6 +4,7 @@ import (
"fmt"
"github.com/opentracing/opentracing-go/log"
"github.com/openziti-test-kitchen/zrok/cmd/zrok/endpoint_ui"
"github.com/sirupsen/logrus"
"github.com/spf13/cobra"
"html/template"
"net"
@ -56,8 +57,11 @@ func (cmd *testEndpointCommand) run(_ *cobra.Command, _ []string) {
}
func (cmd *testEndpointCommand) handleIndex(w http.ResponseWriter, r *http.Request) {
logrus.Infof("%v {%v} -> /index.html", r.RemoteAddr, r.Host)
ed := &endpointData{
Now: time.Now(),
Now: time.Now(),
Host: r.Host,
Remote: r.RemoteAddr,
}
ed.getIps()
if err := cmd.t.Execute(w, ed); err != nil {
@ -66,8 +70,10 @@ func (cmd *testEndpointCommand) handleIndex(w http.ResponseWriter, r *http.Reque
}
type endpointData struct {
Now time.Time
Ips string
Now time.Time
Host string
Remote string
Ips string
}
func (ed *endpointData) getIps() {