additional fields in JSON response

This commit is contained in:
Łukasz Budnik
2021-08-24 21:25:44 +02:00
parent 54942ada28
commit f35f940d90
4 changed files with 88 additions and 41 deletions

View File

@@ -14,7 +14,11 @@ import (
type response struct {
Host string `json:"host"`
Proto string `json:"proto"`
Method string `json:"method"`
Scheme string `json:"scheme"`
RequestURI string `json:"requestUri"`
URL string `json:"url"`
RemoteAddr string `json:"remoteAddr"`
Counter int `json:"counter"`
Headers map[string][]string `json:"headers"`
@@ -52,7 +56,11 @@ func handler(w http.ResponseWriter, req *http.Request) {
response.RequestURI = req.RequestURI
response.Host = req.Host
response.Proto = req.Proto
response.Method = req.Method
response.Scheme = req.URL.Scheme
response.Headers = req.Header
response.URL = req.URL.String()
response.Hostname = hostname