From 83720a317ec22f56413c424cf9fb0c6f165a3d9a Mon Sep 17 00:00:00 2001 From: "Alexander \"Arav\" Andreev" Date: Sun, 14 May 2023 03:51:35 +0400 Subject: [PATCH] Create new category implemented. --- internal/http/api_handlers.go | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/internal/http/api_handlers.go b/internal/http/api_handlers.go index a921091..1c2bc73 100644 --- a/internal/http/api_handlers.go +++ b/internal/http/api_handlers.go @@ -230,7 +230,11 @@ func (h *MindflowApiHandlers) New(w http.ResponseWriter, r *http.Request) { category_id, _ := strconv.ParseInt(r.FormValue("category"), 10, 64) if category_id == 0 { - // TODO: create category + category_id, err = h.db.NewCategory(r.FormValue("new-category")) + if err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } } post, err = mindflow.NewPost(mindflow.Category{ID: category_id}, r.FormValue("title"), r.FormValue("body"))