Skip to content

Commit

Permalink
Sockets: fix routing on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
Morfent committed May 27, 2017
1 parent 62c9ad3 commit 6f016e5
Showing 1 changed file with 9 additions and 9 deletions.
18 changes: 9 additions & 9 deletions sockets/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -40,12 +40,9 @@ func main() {
// FIXME: this doesn't route correctly on Windows. Fix it!!
r := mux.NewRouter()

avatarDir, _ := filepath.Abs("./config/avatars")
r.PathPrefix("/avatars/").
Handler(http.FileServer(http.Dir(avatarDir)))

customCSSDir, _ := filepath.Abs("./config")
r.Handle("/custom.css", http.FileServer(http.Dir(customCSSDir)))
staticDir, _ := filepath.Abs("./static")
r.PathPrefix("/static/").
Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))

// Set up the SockJS server.
opts := sockjs.Options{
Expand All @@ -58,9 +55,12 @@ func main() {
r.PathPrefix("/showdown").
Handler(sockjs.NewHandler("/showdown", opts, smux.Handler))

staticDir, _ := filepath.Abs("./static")
r.PathPrefix("/static/").
Handler(http.StripPrefix("/static/", http.FileServer(http.Dir(staticDir))))
customCSSDir, _ := filepath.Abs("./config")
r.Handle("/custom.css", http.FileServer(http.Dir(customCSSDir)))

avatarDir, _ := filepath.Abs("./config/avatars")
r.PathPrefix("/avatars/").
Handler(http.FileServer(http.Dir(avatarDir)))

r.NotFoundHandler =
http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) {
Expand Down

0 comments on commit 6f016e5

Please sign in to comment.