LEFT | RIGHT |
1 // Copyright 2012 The Go Authors. All rights reserved. | 1 // Copyright 2012 The Go Authors. All rights reserved. |
2 // Use of this source code is governed by a BSD-style | 2 // Use of this source code is governed by a BSD-style |
3 // license that can be found in the LICENSE file. | 3 // license that can be found in the LICENSE file. |
4 | 4 |
5 package http_test | 5 package http_test |
6 | 6 |
7 import ( | 7 import ( |
8 "fmt" | 8 "fmt" |
9 "io/ioutil" | 9 "io/ioutil" |
10 "log" | 10 "log" |
(...skipping 32 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
43 log.Fatal(err) | 43 log.Fatal(err) |
44 } | 44 } |
45 robots, err := ioutil.ReadAll(res.Body) | 45 robots, err := ioutil.ReadAll(res.Body) |
46 if err != nil { | 46 if err != nil { |
47 log.Fatal(err) | 47 log.Fatal(err) |
48 } | 48 } |
49 res.Body.Close() | 49 res.Body.Close() |
50 fmt.Printf("%s", robots) | 50 fmt.Printf("%s", robots) |
51 } | 51 } |
52 | 52 |
53 func ExampleStripPrefix() { | 53 func ExampleFileServer() { |
54 // we use StripPrefix so that /tmpfiles/somefile will access /tmp/somefi
le | 54 // we use StripPrefix so that /tmpfiles/somefile will access /tmp/somefi
le |
55 http.Handle("/tmpfiles/", http.StripPrefix("/tmpfiles/", http.FileServer
(http.Dir("/tmp")))) | 55 http.Handle("/tmpfiles/", http.StripPrefix("/tmpfiles/", http.FileServer
(http.Dir("/tmp")))) |
56 } | 56 } |
LEFT | RIGHT |