Skip to content

Instantly share code, notes, and snippets.

@hugodias
Last active April 24, 2019 00:35
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save hugodias/1251e8cf6878d748561348b089331f5a to your computer and use it in GitHub Desktop.
Save hugodias/1251e8cf6878d748561348b089331f5a to your computer and use it in GitHub Desktop.
func enableCorsJson(fn http.HandlerFunc) http.HandlerFunc {
return func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Content-Type", "application/json")
w.Header().Add("Access-Control-Allow-Origin", "*")
fn(w, r)
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment