Started to work the shortcodes

This commit is contained in:
cdricms
2025-01-24 18:07:04 +01:00
parent 78ce2b533b
commit f1a49eea83
19 changed files with 713 additions and 38 deletions

View File

@@ -3,7 +3,6 @@ package api
import (
"context"
"encoding/json"
"io"
"log"
"net/http"
@@ -11,26 +10,15 @@ import (
)
func HandleCreateUser(w http.ResponseWriter, r *http.Request) {
body, err := io.ReadAll(r.Body)
if err != nil {
core.JSONError{
Status: core.Error,
Message: "The body of your message is invalid.",
}.Respond(w, http.StatusNotAcceptable)
return
}
log.Println("body : ", body )
var user core.User
err = json.Unmarshal(body, &user)
err := json.NewDecoder(r.Body).Decode(&user)
if err != nil {
core.JSONError{
Status: core.Error,
Message: "It seems your body in invalid JSON.",
Message: err.Error(),
}.Respond(w, http.StatusNotAcceptable)
return
}
log.Println("User : ", user)
res, err := user.Insert(context.Background())