aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShenghou Ma <minux.ma@gmail.com>2012-04-20 00:41:10 +0800
committerShenghou Ma <minux.ma@gmail.com>2012-04-20 00:41:10 +0800
commit554316495f0507d68583bb2b54f9b03777a5ed0c (patch)
treefba56da93ef8ae28d8b2490bac3e0be145a79706
parent69a8369b8778d3e8c83fbc0fd7f2f2dc5ee9081a (diff)
downloadgo-554316495f0507d68583bb2b54f9b03777a5ed0c.tar.gz
go-554316495f0507d68583bb2b54f9b03777a5ed0c.zip
[release-branch.go1] net/http: add example for FileServer to mention StripPrefix
««« backport 362b760ecfc7 net/http: add example for FileServer to mention StripPrefix Fixes #3530. R=golang-dev, rsc, bradfitz CC=golang-dev https://golang.org/cl/6032052 »»»
-rw-r--r--src/pkg/net/http/example_test.go5
1 files changed, 5 insertions, 0 deletions
diff --git a/src/pkg/net/http/example_test.go b/src/pkg/net/http/example_test.go
index 2584afc439..ec814407dd 100644
--- a/src/pkg/net/http/example_test.go
+++ b/src/pkg/net/http/example_test.go
@@ -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"))))
+}