diff options
author | Baitinq <manuelpalenzuelamerino@gmail.com> | 2024-05-01 21:27:15 +0200 |
---|---|---|
committer | Baitinq <manuelpalenzuelamerino@gmail.com> | 2024-05-01 21:27:15 +0200 |
commit | 7bcb9b639b064e17b13f99fb353448166a1ed145 (patch) | |
tree | 2c8080e7238ec43185ee0b8fb045335f03ab5025 /src/rest-api/cmd/main.go | |
parent | Flake: Add gopls dependency (diff) | |
download | fs-tracer-backend-7bcb9b639b064e17b13f99fb353448166a1ed145.tar.gz fs-tracer-backend-7bcb9b639b064e17b13f99fb353448166a1ed145.tar.bz2 fs-tracer-backend-7bcb9b639b064e17b13f99fb353448166a1ed145.zip |
rest-api: return request body as string
Diffstat (limited to '')
-rw-r--r-- | src/rest-api/cmd/main.go | 8 |
1 files changed, 7 insertions, 1 deletions
diff --git a/src/rest-api/cmd/main.go b/src/rest-api/cmd/main.go index af72f82..56cc6a3 100644 --- a/src/rest-api/cmd/main.go +++ b/src/rest-api/cmd/main.go @@ -2,6 +2,7 @@ package main import ( "fmt" + "io" "net/http" ) @@ -12,5 +13,10 @@ func main() { } func handleRequest(w http.ResponseWriter, r *http.Request) { - fmt.Fprint(w, "Hello, World!", r.Body) + bytes, err := io.ReadAll(io.Reader(r.Body)) + if err != nil { + panic(err) + } + + fmt.Fprint(w, "Hello, World!", string(bytes)) } |