diff options
Diffstat (limited to 'backend')
-rw-r--r-- | backend/readme.adoc | 93 | ||||
-rw-r--r-- | backend/recipe.go | 5 |
2 files changed, 48 insertions, 50 deletions
diff --git a/backend/readme.adoc b/backend/readme.adoc index 0dec0b2..bc3c50f 100644 --- a/backend/readme.adoc +++ b/backend/readme.adoc @@ -1,7 +1,7 @@ Backend API =========== Tucker Evans -v1.0, November 22, 2019 +v1.1, December 9, 2019 This REST API allows you to access recipe information in our database with simple HTTP requests. There is currently no authentication/authorization of @@ -16,41 +16,40 @@ The current implementation expects (and returns) recipes in the form: [source,json] ---- { - "Id": 0, - "Title": "Recipe Title", - "Desc": "Recipe Description", - "Photos": [ + "id": 0, + "name": "Recipe name", + "description": "Recipe Description", + "photos": [ "photo_url_1", "photo_url_2" ], - "Serving_size": 0, - "Cook_time": 0, - "Rating": 0, - "Num_cooked": 0, - "Keywords": [ + "servingSize": 0, + "cookTime": 0, + "rating": 0, + "timesCooked": 0, + "tags": [ "keyword 1", "keyword 2", "keyword 3" ], - "Ingredients": [ + "ingredients": [ { - "Name": "Ingredient 1 Name", - "Amount": 1.0, - "Unit": "Ingredient Units" + "name": "Ingredient 1 Name", + "amount": 1.0, + "unit": "Ingredient Units" }, ], - "Steps": [ + "steps": [ { - "Num": 0, - "Desc": "Step Instructions/Description", - "Time": 0 + "instruction": "Step Instructions/Description", + "timer": 0 } ] } ---- [NOTE] -`"Id"` is not required for a POST request, and will be ignored. +`"id"` is not required for a POST request, and will be ignored. [IMPORTANT] Keywords and Photo URLs are currently stored as pipe separated values, the @@ -110,23 +109,23 @@ recipe object in JSON form: ---- $ curl -X POST api.recipebuddy.xyz:8888/recipes -d ' { - "Title":"Test Recipe 2", - "Desc":"This is a descripiton for the test recipe", - "Photos":["photo_url_1","photo_url_2"], - "Serving_size":0, - "Cook_time":60, - "Rating":5, - "Keywords":["keyword_1", "keyword_2","keyword_3"], - "Ingredients":[ - {"Name":"INGR 1","Amount":2.5,"Unit":"cups"}, - {"Name":"INGR 2","Amount":1,"Unit":"oz"} + "name":"Test Recipe 2", + "description":"This is a descripiton for the test recipe", + "photos":["photo_url_1","photo_url_2"], + "servingSize":0, + "cookTime":60, + "rating":5, + "tags":["keyword_1", "keyword_2","keyword_3"], + "ingredients":[ + {"name":"INGR 1","amount":2.5,"unit":"cups"}, + {"name":"INGR 2","amount":1,"unit":"oz"} ], - "Steps":[ - {"Num":1,"Desc":"Step 1: Do this first","Time":10} + "steps":[ + {"instruction":"Step 1: Do this first","timer":10} ] }' -{"Status":{"Code":201,"Msg":"Recipe added successfully"},"Data":{"Id":2,"Title":"Test Recipe 2","Desc":"This is a descripiton for the test recipe","Photos":["photo_url_1","photo_url_2"],"Serving_size":0,"Cook_time":60,"Rating":5,"Num_cooked":0,"Keywords":["keyword_1","keyword_2","keyword_3"],"Ingredients":[{"Name":"INGR 1","Amount":2.5,"Unit":"cups"},{"Name":"INGR 2","Amount":1,"Unit":"oz"}],"Steps":[{"Num":1,"Desc":"Step 1: Do this first","Time":10}]}} +{"Status":{"Code":201,"Msg":"Recipe added successfully"},"Data":{"id":2,"name":"Test Recipe 2","description":"This is a descripiton for the test recipe","photos":["photo_url_1","photo_url_2"],"servingSize":0,"cookTime":60,"rating":5,"timesCooked":0,"tags":["keyword_1","keyword_2","keyword_3"],"ingredients":[{"name":"INGR 1","amount":2.5,"unit":"cups"},{"name":"INGR 2","amount":1,"unit":"oz"}],"steps":[{"instruction":"Step 1: Do this first","timer":10}]}} ---- Read @@ -138,7 +137,7 @@ http://api.recipebuddy.xyz:8888/recipes/0[`/recipes/{id}`], the HTTP body is ign ---- $ curl -X GET api.recipebuddy.xyz:8888/recipes/1 -{"Status":{"Code":200,"Msg":"Successful"},"Data":{"Id":1,"Title":"Test Recipe","Desc":"This is a descripiton for the test recipe","Photos":["photo_url_1","photo_url_2",""],"Serving_size":0,"Cook_time":60,"Rating":5,"Num_cooked":0,"Keywords":["keyword_1","keyword_2","keyword_3",""],"Ingredients":[{"Name":"INGR 1","Amount":2.5,"Unit":"cups"},{"Name":"INGR 2","Amount":1,"Unit":"oz"}],"Steps":[{"Num":1,"Desc":"Step 1: Do this first","Time":10}]}} +{"Status":{"Code":200,"Msg":"Successful"},"Data":{"id":1,"name":"Test Recipe","description":"This is a descripiton for the test recipe","photos":["photo_url_1","photo_url_2",""],"servingSize":0,"cookTime":60,"rating":5,"timesCooked":0,"tags":["keyword_1","keyword_2","keyword_3",""],"ingredients":[{"name":"INGR 1","amount":2.5,"unit":"cups"},{"name":"INGR 2","amount":1,"unit":"oz"}],"steps":[{"instruction":"Step 1: Do this first","timer":10}]}} ---- To access a list of all recipe ids in the database send a `GET` request to @@ -158,24 +157,24 @@ complete recipe in JSON form. ---- $ curl -X PUT localhost:8888/recipes/1 -d ' { - "Id": 1, - "Title":"Test Recipe 1", - "Desc":"This is a descripiton for the test recipe", - "Photos":[ "photo_url_1", "photo_url_2" ], - "Serving_size":0, - "Cook_time":60, - "Rating":5, - "Keywords":[ "keyword_1", "keyword_2", "keyword_3" ], - "Ingredients":[ - { "Name":"INGR 1", "Amount":2.5, "Unit":"cups" }, - { "Name":"INGR 2", "Amount":1, "Unit":"oz" } + "id": 1, + "name":"Test Recipe 1", + "description":"This is a descripiton for the test recipe", + "photos":[ "photo_url_1", "photo_url_2" ], + "servingSize":0, + "cookTime":60, + "rating":5, + "tags":[ "keyword_1", "keyword_2", "keyword_3" ], + "ingredients":[ + { "name":"INGR 1", "amount":2.5, "unit":"cups" }, + { "name":"INGR 2", "amount":1, "unit":"oz" } ], - "Steps":[ - { "Num":0, "Desc":"Step 1: Do this first", "Time":10 } + "steps":[ + { "instruction":"Step 1: Do this first", "timer":10 } ] }' -{"Status":{"Code":201,"Msg":"Recipe added successfully"},"Data":{"Id":1,"Title":"Test Recipe 1","Desc":"This is a descripiton for the test recipe","Photos":["photo_url_1","photo_url_2"],"Serving_size":0,"Cook_time":60,"Rating":5,"Num_cooked":0,"Keywords":["keyword_1","keyword_2","keyword_3"],"Ingredients":[{"Name":"INGR 1","Amount":2.5,"Unit":"cups"},{"Name":"INGR 2","Amount":1,"Unit":"oz"}],"Steps":[{"Num":0,"Desc":"Step 1: Do this first","Time":10}]}} +{"Status":{"Code":201,"Msg":"Recipe added successfully"},"Data":{"id":1,"name":"Test Recipe 1","description":"This is a descripiton for the test recipe","photos":["photo_url_1","photo_url_2"],"servingSize":0,"cookTime":60,"rating":5,"timesCooked":0,"tags":["keyword_1","keyword_2","keyword_3"],"ingredients":[{"name":"INGR 1","amount":2.5,"unit":"cups"},{"name":"INGR 2","amount":1,"unit":"oz"}],"steps":[{"instruction":"Step 1: Do this first","timer":10}]}} ---- [WARNING] diff --git a/backend/recipe.go b/backend/recipe.go index a3191c3..59b7366 100644 --- a/backend/recipe.go +++ b/backend/recipe.go @@ -6,12 +6,11 @@ import "strings" type Ingredient struct { Name string `json:"name"` Amount float64 `json:"amount"` - Unit string `json:"units"` - Type string `json:"type"` + Unit string `json:"unit"` } type Step struct { - Desc string `json:"instructions"` + Desc string `json:"instruction"` Time int `json:"timer"` } |