package categories import ( "gis/app" "net/http" ) func deleteCategoryRoute(application *app.App) http.HandlerFunc { return func(w http.ResponseWriter, r *http.Request) { id := r.PathValue("id") tag, err := application.Db.Exec(application.Ctx, "DELETE FROM categories WHERE id=$1", id, ) if err != nil { w.WriteHeader(http.StatusInternalServerError) return } if tag.RowsAffected() == 0 { w.WriteHeader(http.StatusNotFound) return } w.WriteHeader(http.StatusNoContent) } }