|
|
@@ -12,9 +12,17 @@ import ( |
|
|
|
"strings" |
|
|
|
) |
|
|
|
|
|
|
|
const ( |
|
|
|
defaultCorsHeader = "*" |
|
|
|
) |
|
|
|
|
|
|
|
var ( |
|
|
|
corsHeader string |
|
|
|
) |
|
|
|
|
|
|
|
func boardHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
w.Header().Add("Content-Type", "application/json") |
|
|
|
w.Header().Add("Access-Control-Allow-Origin", "*") |
|
|
|
w.Header().Add("Access-Control-Allow-Origin", corsHeader) |
|
|
|
if r.Method != "GET" { |
|
|
|
//w.WriteHeader(405) |
|
|
|
errorResponse(405, "Non-GET method not allowed at this endpoint", w, r) |
|
|
@@ -76,7 +84,7 @@ func boardHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
func playerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
w.Header().Add("Content-Type", "application/json") |
|
|
|
w.Header().Add("Access-Control-Allow-Origin", "*") |
|
|
|
w.Header().Add("Access-Control-Allow-Origin", corsHeader) |
|
|
|
if r.Method != "GET" { |
|
|
|
//w.WriteHeader(405) |
|
|
|
errorResponse(405, "Non-GET method not allowed at this endpoint", w, r) |
|
|
@@ -131,7 +139,7 @@ func playerHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
func newEntryHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
w.Header().Add("Content-Type", "application/json") |
|
|
|
w.Header().Add("Access-Control-Allow-Origin", "*") |
|
|
|
w.Header().Add("Access-Control-Allow-Origin", corsHeader) |
|
|
|
if r.Method != "POST" { |
|
|
|
//w.WriteHeader(405) |
|
|
|
errorResponse(405, "Non-POST method not allowed at this endpoint", w, r) |
|
|
@@ -183,7 +191,7 @@ func newEntryHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
|
|
|
|
func newKeyHandler(w http.ResponseWriter, r *http.Request) { |
|
|
|
w.Header().Add("Content-Type", "application/json") |
|
|
|
w.Header().Add("Access-Control-Allow-Origin", "*") |
|
|
|
w.Header().Add("Access-Control-Allow-Origin", corsHeader) |
|
|
|
if r.Method != "POST" { |
|
|
|
errorResponse(405, "Non-POST method not allowed at this endpoint", w, r) |
|
|
|
return |
|
|
|