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 43
|
package server
import (
"net/http"
"github.com/gin-gonic/gin"
"github.com/henrybear327/go-proton-api"
)
func (s *Server) handleGetEvents() gin.HandlerFunc {
return func(c *gin.Context) {
event, more, err := s.b.GetEvent(c.GetString("UserID"), c.Param("eventID"))
if err != nil {
_ = c.AbortWithError(http.StatusBadRequest, err)
return
}
c.JSON(
http.StatusOK,
struct {
proton.Event
More proton.Bool
}{
event,
proton.Bool(more),
},
)
}
}
func (s *Server) handleGetEventsLatest() gin.HandlerFunc {
return func(c *gin.Context) {
eventID, err := s.b.GetLatestEventID(c.GetString("UserID"))
if err != nil {
_ = c.AbortWithError(http.StatusBadRequest, err)
return
}
c.JSON(http.StatusOK, gin.H{
"EventID": eventID,
})
}
}
|