Spaces:
Runtime error
Runtime error
File size: 1,171 Bytes
c704b7f | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 | package controllers
import (
"abdanhafidz.com/event-booking-api/models/dto"
http_error "abdanhafidz.com/event-booking-api/models/error"
"abdanhafidz.com/event-booking-api/services"
"github.com/gin-gonic/gin"
)
// Referenced by the swagger annotations below.
var _ dto.EventResponse
type EventController interface {
Get(ctx *gin.Context)
}
type eventController struct {
eventService services.EventService
}
func NewEventController(eventService services.EventService) EventController {
return &eventController{eventService: eventService}
}
// Get Event godoc
// @Summary Get an event
// @Description Event with its ticket types and live availability
// @Tags Event
// @Produce json
// @Param id path string true "Event ID"
// @Success 200 {object} dto.SuccessResponse[dto.EventResponse]
// @Failure 404 {object} dto.ErrorResponse
// @Router /v1/events/{id} [get]
func (c *eventController) Get(ctx *gin.Context) {
id, ok := ParseUUIDParam(ctx, "id", http_error.EVENT_NOT_FOUND)
if !ok {
return
}
res, err := c.eventService.Get(ctx.Request.Context(), id)
ResponseJSON[any, any](ctx, nil, res, err)
}
|