diff options
author | Russ Cox <rsc@golang.org> | 2010-06-08 17:51:57 -0700 |
---|---|---|
committer | Russ Cox <rsc@golang.org> | 2010-06-08 17:51:57 -0700 |
commit | 11704e355aa8f39669a36fe56c01d17deab60658 (patch) | |
tree | 9650da2944370ff57a40bc0accdc6665dce42722 /src/pkg/http/triv.go | |
parent | e577f85b2d2908bc727a91a7a5b9f79367f3d48c (diff) | |
download | golang-11704e355aa8f39669a36fe56c01d17deab60658.tar.gz |
misc cleanup: gofmt + &x -> x[0:] conversion
R=gri
CC=golang-dev
http://codereview.appspot.com/1620042
Diffstat (limited to 'src/pkg/http/triv.go')
-rw-r--r-- | src/pkg/http/triv.go | 15 |
1 files changed, 11 insertions, 4 deletions
diff --git a/src/pkg/http/triv.go b/src/pkg/http/triv.go index dea2c23b0..612b6161e 100644 --- a/src/pkg/http/triv.go +++ b/src/pkg/http/triv.go @@ -6,13 +6,12 @@ package main import ( "bytes" - "bufio" "expvar" "flag" "fmt" + "http" "io" "log" - "net" "os" "strconv" ) @@ -67,7 +66,7 @@ func FileServer(c *http.Conn, req *http.Request) { fmt.Fprintf(c, "open %s: %v\n", path, err) return } - n, err1 := io.Copy(c, f) + n, _ := io.Copy(c, f) fmt.Fprintf(c, "[%d bytes]\n", n) f.Close() } @@ -89,7 +88,7 @@ func FlagServer(c *http.Conn, req *http.Request) { // simple argument server func ArgServer(c *http.Conn, req *http.Request) { - for i, s := range os.Args { + for _, s := range os.Args { fmt.Fprint(c, s, " ") } } @@ -138,6 +137,13 @@ func DateServer(c *http.Conn, req *http.Request) { } } +func Logger(c *http.Conn, req *http.Request) { + log.Stdout(req.URL.Raw) + c.WriteHeader(404) + c.Write([]byte("oops")) +} + + func main() { flag.Parse() @@ -146,6 +152,7 @@ func main() { http.Handle("/counter", ctr) expvar.Publish("counter", ctr) + http.Handle("/", http.HandlerFunc(Logger)) http.Handle("/go/", http.HandlerFunc(FileServer)) http.Handle("/flags", http.HandlerFunc(FlagServer)) http.Handle("/args", http.HandlerFunc(ArgServer)) |