about summary refs log tree commit diff
path: root/src/rest-api/cmd/main.go
diff options
context:
space:
mode:
authorBaitinq <manuelpalenzuelamerino@gmail.com>2024-05-01 21:27:15 +0200
committerBaitinq <manuelpalenzuelamerino@gmail.com>2024-05-01 21:27:15 +0200
commit7bcb9b639b064e17b13f99fb353448166a1ed145 (patch)
tree2c8080e7238ec43185ee0b8fb045335f03ab5025 /src/rest-api/cmd/main.go
parentFlake: Add gopls dependency (diff)
downloadfs-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.go8
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))
 }