summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--backend/main.go13
1 files changed, 12 insertions, 1 deletions
diff --git a/backend/main.go b/backend/main.go
index f5a6e52..135d18d 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -21,7 +21,18 @@ func SingleRecipe(w http.ResponseWriter, r *http.Request) {
return
}
if r.Method == "GET" {
- fmt.Printf("Return recipe \"%d\"...\n", recipe_id)
+ recipe := RecipeFromId(recipe_id, db)
+ if recipe == nil {
+ recipe = MakeRecipe()
+ }
+
+ output, err := json.MarshalIndent(recipe, "", " ")
+ if err != nil {
+ fmt.Println("Error converting to JSON")
+ } else {
+ fmt.Println(string(output))
+ }
+
} else if r.Method == "POST" {
fmt.Printf("Create recipe \"%d\"...\n", recipe_id)
} else if r.Method == "PUT" {