feat: daily vani
This commit is contained in:
@@ -0,0 +1,28 @@
|
||||
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)
|
||||
}
|
||||
Reference in New Issue
Block a user