update recipe now can select recipe file
This commit is contained in:
parent
b25c836f0c
commit
b5cb469a30
11 changed files with 209 additions and 236173 deletions
|
|
@ -35,7 +35,9 @@ func (rr *RecipeRouter) Route(r chi.Router) {
|
|||
take = newTake
|
||||
}
|
||||
|
||||
recipe := rr.data.GetRecipe()
|
||||
version := r.URL.Query().Get("version")
|
||||
|
||||
recipe := rr.data.GetRecipe(version)
|
||||
searchQuery := r.URL.Query().Get("search")
|
||||
|
||||
if searchQuery != "" {
|
||||
|
|
@ -62,8 +64,9 @@ func (rr *RecipeRouter) Route(r chi.Router) {
|
|||
}
|
||||
|
||||
json.NewEncoder(w).Encode(map[string]interface{}{
|
||||
"recipes": recipe,
|
||||
"hasMore": isHasMore,
|
||||
"fileName": rr.data.CurrentVersion,
|
||||
"recipes": recipe,
|
||||
"hasMore": isHasMore,
|
||||
})
|
||||
})
|
||||
|
||||
|
|
@ -86,9 +89,15 @@ func (rr *RecipeRouter) Route(r chi.Router) {
|
|||
http.Error(w, "Recipe not found", http.StatusNotFound)
|
||||
})
|
||||
|
||||
r.Get("/json", func(w http.ResponseWriter, r *http.Request) {
|
||||
r.Get("/{version}/json", func(w http.ResponseWriter, r *http.Request) {
|
||||
version := chi.URLParam(r, "version")
|
||||
|
||||
w.Header().Add("Content-Type", "application/json")
|
||||
json.NewEncoder(w).Encode(rr.data.GetRecipe())
|
||||
json.NewEncoder(w).Encode(rr.data.GetRecipe(version))
|
||||
})
|
||||
|
||||
r.Get("/versions", func(w http.ResponseWriter, r *http.Request) {
|
||||
json.NewEncoder(w).Encode(rr.data.AllVersions)
|
||||
})
|
||||
})
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue