diff --git a/README.md b/README.md index 72d714d..b123c31 100644 --- a/README.md +++ b/README.md @@ -55,6 +55,7 @@ Heath check. | `port` | `WHOAMI_PORT_NUMBER` | Give me a port number. (default: `80`) | | `name` | `WHOAMI_NAME` | Give me a name. | | `verbose` | | Enable verbose logging. | +| `no-data` | | Disable data handler. | ## Examples diff --git a/app.go b/app.go index 49ce421..eb2587e 100644 --- a/app.go +++ b/app.go @@ -43,10 +43,12 @@ var ( port string name string verbose bool + no_data bool ) func init() { flag.BoolVar(&verbose, "verbose", false, "Enable verbose logging") + flag.BoolVar(&no_data, "no-data", false, "Disable data handler") flag.StringVar(&cert, "cert", "", "give me a certificate") flag.StringVar(&key, "key", "", "give me a key") flag.StringVar(&ca, "cacert", "", "give me a CA chain, enforces mutual TLS") @@ -166,6 +168,11 @@ func printBinary(s []byte) { } func dataHandler(w http.ResponseWriter, r *http.Request) { + if no_data { + _, _ = fmt.Fprintln(w, "dataHandler disabled!") + return + } + queryParams := r.URL.Query() size, err := strconv.ParseInt(queryParams.Get("size"), 10, 64)