Skip to content

Commit

Permalink
Merge pull request #314 from nicksardo/echo-version
Browse files Browse the repository at this point in the history
Add server version to echo
  • Loading branch information
nicksardo authored Jun 6, 2018
2 parents 0905182 + c48d5cd commit 8f83638
Show file tree
Hide file tree
Showing 2 changed files with 20 additions and 14 deletions.
31 changes: 17 additions & 14 deletions cmd/echo/app/handlers.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (
"time"

"github.com/golang/glog"
"k8s.io/ingress-gce/pkg/version"
)

const (
Expand Down Expand Up @@ -80,21 +81,23 @@ func echo(w http.ResponseWriter, r *http.Request) {
w.WriteHeader(http.StatusOK)

var dump = struct {
Method string `json:"method"`
URI string `json:"uri"`
HTTPVersion string `json:"httpVersion"`
K8sEnv Env `json:"k8sEnv"`
RemoteAddr string `json:"remoteAddr"`
TLS bool `json:"tls"`
Header map[string][]string `json:"header"`
Method string `json:"method"`
URI string `json:"uri"`
HTTPVersion string `json:"httpVersion"`
K8sEnv Env `json:"k8sEnv"`
RemoteAddr string `json:"remoteAddr"`
TLS bool `json:"tls"`
Header map[string][]string `json:"header"`
ServerVersion string `json:"serverVersion"`
}{
Method: r.Method,
URI: r.RequestURI,
HTTPVersion: fmt.Sprintf("%d.%d", r.ProtoMajor, r.ProtoMinor),
K8sEnv: E,
RemoteAddr: r.RemoteAddr,
Header: r.Header,
TLS: r.TLS != nil,
Method: r.Method,
URI: r.RequestURI,
HTTPVersion: fmt.Sprintf("%d.%d", r.ProtoMajor, r.ProtoMinor),
K8sEnv: E,
RemoteAddr: r.RemoteAddr,
Header: r.Header,
TLS: r.TLS != nil,
ServerVersion: version.Version,
}

dumpData, err := json.MarshalIndent(dump, "", "\t")
Expand Down
3 changes: 3 additions & 0 deletions cmd/echo/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -20,12 +20,15 @@ import (
"context"
"flag"

"github.com/golang/glog"
"k8s.io/ingress-gce/cmd/echo/app"
"k8s.io/ingress-gce/pkg/version"
)

func main() {
app.RegisterFlags()
flag.Parse()

glog.V(0).Infof("Starting echo: %q", version.Version)
app.RunHTTPServer(context.Background())
}

0 comments on commit 8f83638

Please sign in to comment.