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

@@ -1,7 +1,6 @@
package routers
import (
"encoding/json"
"net/http"
tasks "queues-go/app/storage/mongo/collections"
)
@@ -16,13 +15,11 @@ type TakeResponse struct {
Task *TaskResponse `json:"task"`
}
func Take(w http.ResponseWriter, r *http.Request) {
func Take(r *http.Request) (interface{}, int) {
queue := r.Header.Get("queue")
task, err := tasks.Take(queue)
if err != nil {
println("Error taking")
w.WriteHeader(http.StatusInternalServerError)
return
return nil, http.StatusInternalServerError
}
var response TakeResponse
@@ -36,12 +33,5 @@ func Take(w http.ResponseWriter, r *http.Request) {
}
}
data, err := json.Marshal(response)
if err != nil {
println("Error marshalling")
w.WriteHeader(http.StatusInternalServerError)
return
}
w.Write(data)
return response, http.StatusOK
}