package api import ( "context" "encoding/json" "fmt" "log" "net/http" "time" core "fr.latosa-escrima/api/core" "github.com/uptrace/bun" ) func HandleCreateBlog(w http.ResponseWriter, r *http.Request) { emptyObject := make(map[string]interface{}) emptyJSON, json_err := json.Marshal(emptyObject) if json_err != nil { fmt.Println("Couldn't create the json object") w.Write(emptyJSON) } if r.Method != http.MethodPost { } err := r.ParseForm() if err != nil { } user := &core.Blog{ BaseModel: bun.BaseModel{}, BlogID: [16]byte{}, Slug: "", Content: "", Label: "", AuthorID: [16]byte{}, Published: time.Time{}, Summary: "", Image: "", Href: "", Author: &core.User{}, } _, err_db := core.DB.NewInsert().Model(user).Exec(context.Background()) if err_db != nil { log.Fatal(err) } fmt.Println("User inserted successfully") }