mirror of
https://github.com/arnaucube/go-dvote.git
synced 2026-02-28 05:26:46 +01:00
Adding CORS headers
This commit is contained in:
@@ -7,7 +7,7 @@ Reference implementation of a voting census service running on the Vocdoni platf
|
||||
In a GO ready environment:
|
||||
|
||||
```
|
||||
go get -u github.com/vocdoni/dvote-census
|
||||
go get -u github.com/vocdoni/dvote-census/...
|
||||
go build -o censusHttpService github.com/vocdoni/dvote-census/cmd/censushttp
|
||||
```
|
||||
|
||||
|
||||
@@ -71,7 +71,19 @@ func checkAuth(timestamp, signature, message string) bool {
|
||||
return false
|
||||
}
|
||||
|
||||
func addCorsHeaders(w *http.ResponseWriter, req *http.Request) {
|
||||
(*w).Header().Set("Access-Control-Allow-Origin", "*")
|
||||
(*w).Header().Set("Access-Control-Allow-Methods", "POST, GET, OPTIONS")
|
||||
(*w).Header().Set("Access-Control-Allow-Headers", "Accept, Content-Type, Content-Length, Accept-Encoding, X-CSRF-Token, Authorization")
|
||||
}
|
||||
|
||||
func claimHandler(w http.ResponseWriter, req *http.Request, op string) {
|
||||
addCorsHeaders(&w, req)
|
||||
|
||||
if (*req).Method == "OPTIONS" {
|
||||
return
|
||||
}
|
||||
|
||||
var c Claim
|
||||
var resp Result
|
||||
if ok := checkRequest(w, req); !ok {
|
||||
|
||||
Reference in New Issue
Block a user