From: Shenghou Ma Date: Thu, 19 Apr 2012 16:41:10 +0000 (+0800) Subject: [release-branch.go1] net/http: add example for FileServer to mention StripPrefix X-Git-Tag: go1.0.1~18 X-Git-Url: http://www.git.cypherpunks.su/?a=commitdiff_plain;h=554316495f0507d68583bb2b54f9b03777a5ed0c;p=gostls13.git [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 »»» --- 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")))) +}