diff --git a/src/httpcat.go b/src/httpcat.go index 935fdec..2c14295 100644 --- a/src/httpcat.go +++ b/src/httpcat.go @@ -52,6 +52,25 @@ } +func startServer() { + http.HandleFunc("/", requestHandler) + + if err := http.ListenAndServe(":"+strconv.Itoa(port), nil); err != nil { + fmt.Printf("Could not start server. Is port %d available?\n", port) + } +} + +func sendRequest(uri string) { + response, err := http.Get(uri) + + if(err != nil) { + fmt.Println(err); + } else { + dump, _ := httputil.DumpResponse(response, true) + fmt.Println(string(dump[:])) + } +} + func parseCommandLine() { flag.IntVar(&port, "port", 8080, "") flag.IntVar(&port, "p", 8080, "") @@ -92,25 +111,6 @@ } -func startServer() { - http.HandleFunc("/", requestHandler) - - if err := http.ListenAndServe(":"+strconv.Itoa(port), nil); err != nil { - fmt.Printf("Could not start server. Is port %d available?\n", port) - } -} - -func sendRequest(uri string) { - response, err := http.Get(uri) - - if(err != nil) { - fmt.Println(err); - } else { - dump, _ := httputil.DumpResponse(response, true) - fmt.Println(string(dump[:])) - } -} - var usage = func() { fmt.Fprintf(os.Stderr, "Usage:\n") fmt.Fprintf(os.Stderr, "\n")