added filter and tag for ingredients

This commit is contained in:
2025-10-25 22:13:55 +02:00
parent b8046c87b9
commit cc28aa9a8e
5 changed files with 914 additions and 29 deletions

21
main.go
View File

@@ -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)
}
}
}))