event api v1

This commit is contained in:
gom-by
2025-01-27 11:37:13 +01:00
parent c202764966
commit 18dd8fa1bb
4 changed files with 45 additions and 96 deletions

28
backend/api/get_event.go Normal file
View File

@@ -0,0 +1,28 @@
package api
import (
"context"
"net/http"
core "fr.latosa-escrima/api/core"
)
func HandleGetEvent(w http.ResponseWriter, r *http.Request) {
event_uuid := r.PathValue("event_uuid")
var event core.Event
_, err := core.DB.NewSelect().Model(&event).Where("uuid = ?", event_uuid).ScanAndCount(context.Background())
if err != nil {
core.JSONError{
Status: core.Error,
Message: err.Error(),
}.Respond(w, http.StatusInternalServerError)
return
}
core.JSONSuccess{
Status: core.Success,
Message: "Event successfully sent",
Data: event,
}.Respond(w, http.StatusOK)
return
}