The following code serves the files inside ./data directory on localhost:8080/: log.Fatal(http.ListenAndServe(":8080", http.FileServer(http.Dir("./data"))))
The following code does the same: http.Handle("/", http.FileServer(http.Dir("./data"))) log.Fatal(http.ListenAndServe(":8080", nil)) The following code serves files inside ./data directory on localhost:8080/h. This method is suggested by https://golang.org/pkg/net/http/#FileServer. http.Handle("/h/", http.StripPrefix("/h/", http.FileServer(http.Dir("./data")))) log.Fatal(http.ListenAndServe(":8080", nil)) My first intuition is to use the following code to serve files on localhost:8080/h. It does not work. But no errors report. What does the following code do? http.Handle("/h", http.FileServer(http.Dir("./data"))) log.Fatal(http.ListenAndServe(":8080", nil)) -- You received this message because you are subscribed to the Google Groups "golang-nuts" group. To unsubscribe from this group and stop receiving emails from it, send an email to golang-nuts+unsubscr...@googlegroups.com. To view this discussion on the web visit https://groups.google.com/d/msgid/golang-nuts/79a0c950-a015-47bf-a702-ad8660ac9f7c%40googlegroups.com.