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:
parent
a682540547
commit
acb550504f
@ -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"))))
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user