summaryrefslogtreecommitdiff
path: root/backend/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/main.go')
-rw-r--r--backend/main.go19
1 files changed, 18 insertions, 1 deletions
diff --git a/backend/main.go b/backend/main.go
index 135d18d..4679e73 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -10,7 +10,24 @@ import "encoding/json"
func RecipeList(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
- fmt.Printf("Return all recipe names...\n")
+ var ids []int
+ var id int
+
+ rows, err := db.Query("SELECT id FROM recipes")
+ if err != nil {
+ } else {
+ for rows.Next() {
+ rows.Scan(&id)
+ ids = append(ids, id)
+ }
+ }
+
+ output, err := json.MarshalIndent(ids, "", " ")
+ if err != nil {
+ fmt.Println("Error converting to JSON")
+ } else {
+ fmt.Println(string(output))
+ }
}
}