Files
outfit-voting-abi26/internal/http/vote/result.go
T
tueem 85e4df52a5
build / Go-Build (push) Successful in 1m1s
feat(*): initial commit
2026-06-24 00:16:21 +02:00

34 lines
716 B
Go

package vote
import (
"encoding/json"
"net/http"
"tomatentum.net/outfit-voting-abi26/internal/database"
)
func GetVoteResultEndpoint(w http.ResponseWriter, r *http.Request) {
entries, err := database.GetVotes()
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Add("Content-Type", "application/json")
json.NewEncoder(w).Encode(entries)
}
func GetVoteResultSingleEndoint(w http.ResponseWriter, r *http.Request) {
id := r.PathValue("id")
entry, err := database.GetVote(id)
if err != nil {
http.Error(w, err.Error(), http.StatusInternalServerError)
return
}
w.Header().Add("Content-Type", "application/json")
json.NewEncoder(w).Encode(entry)
}