diff --git a/config/conf.go b/config/conf.go index 0af6d21..cf7cd09 100644 --- a/config/conf.go +++ b/config/conf.go @@ -1,6 +1,7 @@ package config import ( + "io" "log" "math" "net/http" @@ -132,3 +133,11 @@ func ActiveClass(a, b int) string { } return active } + +func WriteBody(r *http.Request) { + if body, err := io.ReadAll(r.Body); err != nil { + log.Println("WriteBody: ", err) + } else { + log.Println("WriteBody: ", string(body)) + } +} diff --git a/handler/web/schedule.go b/handler/web/schedule.go index 6995b8f..2290e59 100644 --- a/handler/web/schedule.go +++ b/handler/web/schedule.go @@ -29,7 +29,42 @@ func (h *ScheduleHandler) HomeHandler(w http.ResponseWriter, r *http.Request) er } func (h *ScheduleHandler) CreateHandler(w http.ResponseWriter, r *http.Request) error { - jsonData, err := config.ConvertStringBoolsToBool(r, "active") + jsonData, err := config.ConvertStringIDsToInt(r, "group_id") + if err != nil { + _, _ = w.Write([]byte(err.Error())) + return nil + } + r.Body = io.NopCloser(strings.NewReader(string(jsonData))) + + jsonData, err = config.ConvertStringIDsToInt(r, "request_id") + if err != nil { + _, _ = w.Write([]byte(err.Error())) + return nil + } + r.Body = io.NopCloser(strings.NewReader(string(jsonData))) + + jsonData, err = config.ConvertStringIDsToInt(r, "notification_id") + if err != nil { + _, _ = w.Write([]byte(err.Error())) + return nil + } + r.Body = io.NopCloser(strings.NewReader(string(jsonData))) + + jsonData, err = config.ConvertStringIDsToInt(r, "timeout") + if err != nil { + _, _ = w.Write([]byte(err.Error())) + return nil + } + r.Body = io.NopCloser(strings.NewReader(string(jsonData))) + + jsonData, err = config.ConvertStringIDsToInt(r, "retries") + if err != nil { + _, _ = w.Write([]byte(err.Error())) + return nil + } + r.Body = io.NopCloser(strings.NewReader(string(jsonData))) + + jsonData, err = config.ConvertStringBoolsToBool(r, "active") if err != nil { _, _ = w.Write([]byte(err.Error())) return nil diff --git a/views/components/schedule/new.gohtml b/views/components/schedule/new.gohtml index 8e21dd2..e439488 100644 --- a/views/components/schedule/new.gohtml +++ b/views/components/schedule/new.gohtml @@ -3,7 +3,7 @@ {{define "scheduleNew" }}
-
+
- - + +