Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add option to disable data endpoint #54

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 7 additions & 0 deletions app.go
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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)
Expand Down