mirror of
https://github.com/stevenhowes/osgrid-server.git
synced 2026-05-27 00:03:38 +01:00
Do some headers to allow use from other domains
This commit is contained in:
@@ -83,6 +83,7 @@ func makeHTTPServer(listenPort string) *http.Server {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func handleError(w http.ResponseWriter, _ *http.Request, str string, _ error) {
|
func handleError(w http.ResponseWriter, _ *http.Request, str string, _ error) {
|
||||||
|
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||||
w.WriteHeader(http.StatusBadRequest)
|
w.WriteHeader(http.StatusBadRequest)
|
||||||
fmt.Fprintf(w, "Invalid request: %q\n", str)
|
fmt.Fprintf(w, "Invalid request: %q\n", str)
|
||||||
}
|
}
|
||||||
@@ -97,6 +98,7 @@ func handle(w http.ResponseWriter, _ *http.Request, ref osgridref.OsGridRef, lat
|
|||||||
}
|
}
|
||||||
|
|
||||||
w.Header().Add("Content-Type", "application/json")
|
w.Header().Add("Content-Type", "application/json")
|
||||||
|
w.Header().Add("Access-Control-Allow-Origin", "*")
|
||||||
enc := json.NewEncoder(w)
|
enc := json.NewEncoder(w)
|
||||||
enc.SetEscapeHTML(false)
|
enc.SetEscapeHTML(false)
|
||||||
err := enc.Encode(reply)
|
err := enc.Encode(reply)
|
||||||
|
|||||||
Reference in New Issue
Block a user