What your code does is when you access localhost:8080/h, it will serve the 
contents of the file ./data/h

If ./data/h does not exist, it will give a 404.

If ./data/h is a directory, it will redirect to /h/  - but then there's no 
route which matches that path, so after following the redirect you'll get a 
404.

Note that "/h" only matches the path /h - if you want a subtree you need 
the trailing slash.

If you changed it to:

http.Handle("/h/", http.FileServer(http.Dir("./data")))
log.Fatal(http.ListenAndServe(":8080", nil))

then you'll find
curl localhost:8080/h/xxx
shows you the contents of data/h/xxx

-- 
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/fd4dd000-4ab4-4615-a347-7e6069c8d2ff%40googlegroups.com.

Reply via email to