From 2b54af9b4bbdbffbf4a76c902cd5dfa8b8ece3aa Mon Sep 17 00:00:00 2001 From: Nils Date: Thu, 23 Dec 2021 01:44:07 +0100 Subject: [PATCH] add fallback to request if it fails --- main.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/main.go b/main.go index 7953dbe..9a92c0b 100644 --- a/main.go +++ b/main.go @@ -52,7 +52,11 @@ func ping(w http.ResponseWriter, req *http.Request) { geturl := strings.Split(req.URL.String(), "/") target := geturl[2] pingres := runner(req.RemoteAddr, "ping", "-c5", target) - fmt.Fprintln(w, pingres) + if pingres != "" { + fmt.Fprintln(w, pingres) + } else { + fmt.Fprintln(w, http.StatusInternalServerError) + } } func main() {