From 554316495f0507d68583bb2b54f9b03777a5ed0c Mon Sep 17 00:00:00 2001 From: Shenghou Ma Date: Fri, 20 Apr 2012 00:41:10 +0800 Subject: [PATCH] [release-branch.go1] net/http: add example for FileServer to mention StripPrefix MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit ««« 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 »»» --- src/pkg/net/http/example_test.go | 5 +++++ 1 file changed, 5 insertions(+) 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")))) +} -- 2.48.1