aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-06 18:14:49 +0530
committerVidhu Kant Sharma <vidhukant@vidhukant.com>2025-05-06 18:14:49 +0530
commitb7456729caa465b74f0cc094ea85fb70488ef196 (patch)
treecdf41a415e1014a0e4a3030e31b342d6d1d7fd3c
parent6c49d1ec3153852f0e5d4cff334a1bc0476f9dce (diff)
using application/x-www-form-urlencoded data instead of application/jsonv1.1.0
-rw-r--r--cmd/serve.go8
1 files changed, 6 insertions, 2 deletions
diff --git a/cmd/serve.go b/cmd/serve.go
index e3d6b36..51fc004 100644
--- a/cmd/serve.go
+++ b/cmd/serve.go
@@ -21,7 +21,6 @@ import (
"fmt"
"log"
"net/http"
- "encoding/json"
"vidhukant.com/guestbook/db"
@@ -83,7 +82,12 @@ var serveCmd = &cobra.Command{
}
var data db.GuestbookEntry
- err := json.NewDecoder(r.Body).Decode(&data)
+ err := r.ParseForm()
+ data.Name = r.FormValue("name")
+ data.Website = r.FormValue("website")
+ data.Message = r.FormValue("message")
+ data.Validation = r.FormValue("validation")
+
if err != nil {
log.Printf("Error occurred while decoding data: %v")
http.Redirect(w, r, errorRedirect, http.StatusSeeOther)