From 51b07a1c715929c7ad4939549df54a6eb7927105 Mon Sep 17 00:00:00 2001 From: Stanislav Pavlovichev Date: Sun, 11 Feb 2018 16:50:55 +0200 Subject: [PATCH] Readme --- README.md | 29 ++++++++++++++++++++++++++++- http-debug-server.go | 8 ++++++-- 2 files changed, 34 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index 32f8733..ab5688e 100644 --- a/README.md +++ b/README.md @@ -1 +1,28 @@ -# http-debug-server \ No newline at end of file +# http-debug-server + +The application provide ability to debug HTTP requests + +## Usage + +``` +http-debug-server -p 8081 +``` + +and then: + +``` +curl -X POST -H 'X-Api-Key: secret' http://localhost:8081/test?foo=bar +``` + +Output: +``` +2018/02/11 16:49:07 POST /test?foo=bar HTTP/1.1 +Host: localhost:8081 +Accept: */* +Content-Length: 2 +Content-Type: application/x-www-form-urlencoded +User-Agent: curl/7.54.0 +X-Api-Key: secret + +{} +``` diff --git a/http-debug-server.go b/http-debug-server.go index fc2d832..5b124b9 100644 --- a/http-debug-server.go +++ b/http-debug-server.go @@ -13,7 +13,7 @@ import ( func main() { app := cli.NewApp() app.Version = "0.9.0" - app.Description = "The application provide ability to debug HTPP requests" + app.Description = "The application provide ability to debug HTTP requests" app.Usage = "HTTP Debug" app.Flags = []cli.Flag{ @@ -33,7 +33,11 @@ func main() { }) log.Println("Listening on: ", port) - http.ListenAndServe(fmt.Sprintf(":%d", port), nil) + err := http.ListenAndServe(fmt.Sprintf(":%d", port), nil) + + if err != nil { + log.Fatalln(err.Error()) + } return nil }