30 lines
516 B
Go
30 lines
516 B
Go
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)
|
|
}
|