Skip to content

Instantly share code, notes, and snippets.

@omeid
Created July 27, 2014 17:39
Show Gist options
  • Save omeid/b2c8e7186a99771b0fbb to your computer and use it in GitHub Desktop.
Save omeid/b2c8e7186a99771b0fbb to your computer and use it in GitHub Desktop.
Go Martin Angular.js html5 urls.
package main
import(
"fmt"
"github.com/go-martini/martini"
)
func main() {
m := m := martini.Classic();
m.NotFound(func(w http.ResponseWriter, r *http.Request) {
// Only rewrite paths *not* containing filenames
if path.Ext(r.URL.Path) == "" {
http.ServeFile(w, r, "public/index.html")
} else {
w.WriteHeader(http.StatusNotFound)
w.Write([]byte("404 page not found"))
}
})
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment