This commit is contained in:
Egor Matveev
2024-12-31 00:53:40 +03:00
commit c2659fb49c
16 changed files with 480 additions and 0 deletions

29
app/routers/finish.go Normal file
View File

@@ -0,0 +1,29 @@
package routers
import (
"encoding/json"
"net/http"
tasks "queues-go/app/storage/mongo/collections"
)
type FinishRequestBody struct {
Id string `json:"id"`
}
func Finish(w http.ResponseWriter, r *http.Request) {
d := json.NewDecoder(r.Body)
body := FinishRequestBody{}
err := d.Decode(&body)
if err != nil {
w.WriteHeader(http.StatusBadRequest)
return
}
err = tasks.Finish(body.Id)
if err != nil {
w.WriteHeader(http.StatusInternalServerError)
return
}
w.WriteHeader(http.StatusAccepted)
}