fix
All checks were successful
Deploy Dev / Build (pull_request) Successful in 39s
Deploy Dev / Push (pull_request) Successful in 24s
Deploy Dev / Deploy dev (pull_request) Successful in 8s
Deploy Prod / Build (pull_request) Successful in 38s
Deploy Prod / Push (pull_request) Successful in 25s
Deploy Prod / Deploy prod (pull_request) Successful in 8s

This commit is contained in:
Egor Matveev
2025-01-01 14:18:19 +03:00
parent 19aff26259
commit 3504e132ad
4 changed files with 26 additions and 28 deletions

View File

@@ -15,13 +15,12 @@ type PutRequestBody struct {
Delay *int `json:"delay"`
}
func Put(w http.ResponseWriter, r *http.Request) {
func Put(r *http.Request) (interface{}, int) {
d := json.NewDecoder(r.Body)
body := PutRequestBody{}
err := d.Decode(&body)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
return nil, http.StatusBadRequest
}
queue := r.Header.Get("queue")
@@ -44,9 +43,8 @@ func Put(w http.ResponseWriter, r *http.Request) {
err = tasks.Add(task)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
return nil, http.StatusInternalServerError
}
w.WriteHeader(http.StatusAccepted)
return nil, http.StatusAccepted
}