1
0
mirror of https://github.com/golang/go synced 2024-11-20 04:04:41 -07:00

net/http: add example for FileServer to mention StripPrefix

Fixes #3530.

R=golang-dev, rsc, bradfitz
CC=golang-dev
https://golang.org/cl/6032052
This commit is contained in:
Shenghou Ma 2012-04-20 00:41:10 +08:00
parent a682540547
commit acb550504f

View File

@ -49,3 +49,8 @@ func ExampleGet() {
res.Body.Close()
fmt.Printf("%s", robots)
}
func ExampleFileServer() {
// we use StripPrefix so that /tmpfiles/somefile will access /tmp/somefile
http.Handle("/tmpfiles/", http.StripPrefix("/tmpfiles/", http.FileServer(http.Dir("/tmp"))))
}