Skip to content

Instantly share code, notes, and snippets.

@venoms
Created May 18, 2016 15:32
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save venoms/f415084af729367c810a7900b117fcde to your computer and use it in GitHub Desktop.
Save venoms/f415084af729367c810a7900b117fcde to your computer and use it in GitHub Desktop.
package main
func cors(h http.Handler) http.Handler {
return http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
w.Header().Set("Access-Control-Allow-Methods", "DELETE")
h(w, r)
})
}
window.onpopstate = function(ev) {
with(new XMLHttpRequest)
addEventListener("load", function(){ document.body.parentElement.innerHTML = this.responseText }),
addEventListener("error", function(){ document.body.parentElement.innerHTML = "it broke" }),
open("DELETE", window.location),
send();
}
Array.prototype.forEach.call(document.getElementsByTagName("a"),function(el){
el.addEventListener("click", function(){ history.pushState(this.href,"", this.href) ; return false })
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment