I am using the julienschmidt/httprouter alongside with http.FileServer.
Something like this:
func main() {
router := httprouter.New()
router.NotFound = http.FileServer(http.Dir("/srv/www/public_html"))
router.GET("/api/user/:id", getUserbyId)
log.Fatal(http.ListenAndServe(":80", router))
}
So if a route is not found just serve them from root dir "/"
But this does not work as intended. In nginx I do it like this
location / {
autoindex on;
try_files $uri $uri/ /index.html =404;
}
Check if there are any files in the given url, if not then give them /index.html
How can I make the server compatible with AngularJS html5mode?