diff options
author | Jacob <gatelyjm@clarkson.edu> | 2019-12-07 03:17:14 -0500 |
---|---|---|
committer | Jacob <gatelyjm@clarkson.edu> | 2019-12-07 03:17:14 -0500 |
commit | c6afa531481b664950406df6cea17794942d8028 (patch) | |
tree | 2c74b9d469a31f5ffbacedb316a0732e4ba2abae /backend | |
parent | 0922e7f865d61295adc6807f2776a80ce70fe711 (diff) | |
parent | 5cf3689290666f70cd631d7b3d40a2ed245a3fce (diff) |
Merge branch 'master' into JacobJacob
Diffstat (limited to 'backend')
-rw-r--r-- | backend/main.go | 10 |
1 files changed, 10 insertions, 0 deletions
diff --git a/backend/main.go b/backend/main.go index 0bd5ebf..001a5cb 100644 --- a/backend/main.go +++ b/backend/main.go @@ -93,6 +93,11 @@ func RecipeList(w http.ResponseWriter, r *http.Request) { sendResponse(w, http.StatusCreated, "Recipe added successfully", recipe) + } else if r.Method == "OPTIONS" { + + w.Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS") //Enable CORS + w.Header().Set("Access-Control-Allow-Headers", "Content-Type") //Enable CORS + sendResponse(w, http.StatusOK, "Set Allowed Methods CORS", nil) } else { sendResponse(w, http.StatusMethodNotAllowed, "Invalid method", nil) @@ -183,6 +188,11 @@ func SingleRecipe(w http.ResponseWriter, r *http.Request) { "Recipe Deleted Successfully", nil) } + } else if r.Method == "OPTIONS" { + + w.Header().Set("Access-Control-Allow-Methods", "POST, GET, PUT, DELETE, OPTIONS") //Enable CORS + w.Header().Set("Access-Control-Allow-Headers", "Content-Type") //Enable CORS + sendResponse(w, http.StatusOK, "Set Allowed Methods CORS", nil) } else { sendResponse(w, http.StatusMethodNotAllowed, "Invalid method", nil) |