diff --git a/docs/guide/essentials/history-mode.md b/docs/guide/essentials/history-mode.md index 5eeaad033..58dd4df21 100644 --- a/docs/guide/essentials/history-mode.md +++ b/docs/guide/essentials/history-mode.md @@ -105,6 +105,31 @@ rewrite { to {path} / } ``` +#### Golang gorilla/mux + +```go +package main +import ( + "net/http" + "os" + "github.com/gorilla/mux" +) +var httpPort = "80" +var indexFile = "index.html" +func serverHandler(w http.ResponseWriter, r *http.Request) { + if _, err := os.Stat(indexFile); err != nil { + http.Error(w, err.Error(), http.StatusInternalServerError) + return + } + http.ServeFile(w, r, indexFile) +} +func main() { + r := mux.NewRouter() + r.NotFoundHandler = r.NewRoute().HandlerFunc(serverHandler).GetHandler() + http.Handle("/", r) + http.ListenAndServe(":"+httpPort, nil) +} +``` #### Firebase hosting