31 lines
609 B
Go
31 lines
609 B
Go
package server
|
|
|
|
import (
|
|
"fmt"
|
|
"net/http"
|
|
|
|
"github.com/gin-gonic/gin"
|
|
)
|
|
|
|
|
|
func (s *Server) GetRecipeOfTheWeekHandler(ctx *gin.Context) {
|
|
// BUG: This needs to be different
|
|
userId := 1
|
|
|
|
recipe, err := s.deps.RecipeService.GetRecipeOfTheWeek(&userId)
|
|
|
|
if err != nil {
|
|
ctx.JSON(http.StatusBadRequest, gin.H{
|
|
"status": http.StatusBadRequest,
|
|
"message": fmt.Sprintf("[ERROR] Failed to get recipe of the week. %s\n", err.Error()),
|
|
})
|
|
return
|
|
}
|
|
|
|
ctx.JSON(http.StatusOK, gin.H{
|
|
"status": http.StatusOK,
|
|
"message": "[OK] Successfully retrieved recipe of the week.\n",
|
|
"recipe": recipe,
|
|
})
|
|
}
|