29 lines
810 B
Go
29 lines
810 B
Go
package handler
|
|
|
|
import (
|
|
"net/http"
|
|
|
|
"github.com/prabhupadasays/spsays-bff/internal/service"
|
|
"github.com/prabhupadasays/spsays-bff/pkg/response"
|
|
)
|
|
|
|
// VaniHandler serves the public "Vāṇī of the Day" pick for the home page.
|
|
type VaniHandler struct {
|
|
svc *service.VaniService
|
|
}
|
|
|
|
func NewVaniHandler(svc *service.VaniService) *VaniHandler {
|
|
return &VaniHandler{svc: svc}
|
|
}
|
|
|
|
// Today — GET /vani/today. Public; the same pick is returned to everyone for
|
|
// the current UTC day. Responds with `data: null` if there's no content.
|
|
func (h *VaniHandler) Today(w http.ResponseWriter, r *http.Request) {
|
|
payload, err := h.svc.Today(r.Context())
|
|
if err != nil {
|
|
response.Error(w, http.StatusInternalServerError, "could not load vāṇī of the day")
|
|
return
|
|
}
|
|
response.JSON(w, http.StatusOK, payload)
|
|
}
|