package api import ( "encoding/json" "net/http" "GoApi/internal/repository" ) type EventController struct { Repo repository.EventRepository } func NewEventController(repo repository.EventRepository) EventController { return EventController{Repo: repo} } func (c EventController) GetEventsHandler(w http.ResponseWriter, r *http.Request) { events, err := c.Repo.GetEvents() if err != nil { http.Error(w, "ERROR: Not found events", http.StatusInternalServerError) return } w.Header().Set("Content-Type", "application/json") json.NewEncoder(w).Encode(events) }