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>
<div id="info"> <div id="info">
<h2>The Current Now is {{ .Now }}</h2> <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> <p>This host has these IP addresses: {{ .Ips }}</p>
</div> </div>
</div> </div>

View File

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