update
This commit is contained in:
parent
5cf0a8b761
commit
28cdbbc4f9
5 changed files with 84 additions and 1 deletions
|
|
@ -50,6 +50,31 @@ func (rr *RecipeRouter) Route(r chi.Router) {
|
|||
r.Route("/recipes", func(r chi.Router) {
|
||||
r.Get("/dashboard", rr.dashBoard)
|
||||
|
||||
r.Get("/{country}/{filename}/all", func(w http.ResponseWriter, r *http.Request) {
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
|
||||
country := r.URL.Query().Get("country")
|
||||
filename := r.URL.Query().Get("filename")
|
||||
|
||||
rr.taoLogger.Log.Debug("RecipeRouter.GetAll", zap.Any("country", country), zap.Any("filename", filename))
|
||||
|
||||
result, err := rr.recipeService.GetAllRecipe(&contracts.GetAllRecipeRequest{
|
||||
Country: country,
|
||||
Filename: filename,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
http.Error(w, err.Error(), http.StatusNotFound)
|
||||
return
|
||||
}
|
||||
|
||||
if err := json.NewEncoder(w).Encode(result); err != nil {
|
||||
rr.taoLogger.Log.Error("RecipeRouter.GetAll", zap.Error(err))
|
||||
http.Error(w, "Internal Error", http.StatusInternalServerError)
|
||||
return
|
||||
}
|
||||
})
|
||||
|
||||
r.Get("/overview", rr.overview)
|
||||
|
||||
r.Get("/{product_code}", rr.getRecipeByProductCode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue