summaryrefslogtreecommitdiff
path: root/backend/main.go
diff options
context:
space:
mode:
Diffstat (limited to 'backend/main.go')
-rw-r--r--backend/main.go14
1 files changed, 13 insertions, 1 deletions
diff --git a/backend/main.go b/backend/main.go
index 9639b74..5b0e8e7 100644
--- a/backend/main.go
+++ b/backend/main.go
@@ -30,9 +30,21 @@ func MakeAPIResponse(status int, msg string, data interface{}) *APIResponse {
}
}
-func RecipeList(w http.ResponseWriter, r *http.Request) {
+func sendResponse(w http.ResponseWriter, code int, msg string, data interface{}) {
w.Header().Set("Access-Control-Allow-Origin", "*") //Enable CORS
+ w.WriteHeader(code)
+
+ resp := MakeAPIResponse(code, msg, data)
+
+ w.Header().Set("Content-Type",
+ "application/json; charset=UTF-8")
+
+ if err := json.NewEncoder(w).Encode(resp); err != nil {
+ panic(err)
+ }
+}
+func RecipeList(w http.ResponseWriter, r *http.Request) {
if r.Method == "GET" {
var ids []int
var id int