refactor: use GetValidatedDTO for vote validation
This commit is contained in:
@@ -78,14 +78,13 @@ func (h *VoteHandler) CastVote(w http.ResponseWriter, r *http.Request) {
|
|||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
req, ok := GetValidatedDTO[dto.CastVoteRequest](r)
|
request, ok := GetValidatedDTO[dto.CastVoteRequest](w, r)
|
||||||
if !ok {
|
if !ok {
|
||||||
SendErrorResponse(w, "Invalid request", http.StatusBadRequest)
|
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
var voteType database.VoteType
|
var voteType database.VoteType
|
||||||
switch req.Type {
|
switch request.Type {
|
||||||
case "up":
|
case "up":
|
||||||
voteType = database.VoteUp
|
voteType = database.VoteUp
|
||||||
case "down":
|
case "down":
|
||||||
|
|||||||
Reference in New Issue
Block a user