added filter and tag for ingredients
This commit is contained in:
21
main.go
21
main.go
@@ -63,10 +63,25 @@ func main() {
|
||||
}
|
||||
}))
|
||||
http.HandleFunc("/ingredients/", auth.RequireAuth(func(w http.ResponseWriter, r *http.Request) {
|
||||
if r.Method == "DELETE" {
|
||||
handlers.DeleteIngredientHandler(w, r)
|
||||
path := r.URL.Path
|
||||
if strings.Contains(path, "/tags") {
|
||||
// Ingredient tag routes
|
||||
if r.Method == "GET" {
|
||||
handlers.GetIngredientTagsHandler(w, r)
|
||||
} else if r.Method == "POST" {
|
||||
handlers.AddIngredientTagHandler(w, r)
|
||||
} else if r.Method == "DELETE" {
|
||||
handlers.RemoveIngredientTagHandler(w, r)
|
||||
} else {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
}
|
||||
} else {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
// Ingredient delete route
|
||||
if r.Method == "DELETE" {
|
||||
handlers.DeleteIngredientHandler(w, r)
|
||||
} else {
|
||||
http.Error(w, "Method not allowed", http.StatusMethodNotAllowed)
|
||||
}
|
||||
}
|
||||
}))
|
||||
|
||||
|
||||
Reference in New Issue
Block a user