aboutsummaryrefslogtreecommitdiff
path: root/src/pkg/http/server.go
diff options
context:
space:
mode:
authorAndrew Gerrand <adg@golang.org>2010-03-29 10:02:37 +1100
committerAndrew Gerrand <adg@golang.org>2010-03-29 10:02:37 +1100
commitdc6f8321b11370a5b3dd2babd64c60228c274e78 (patch)
tree652ceccf89d1ccc3e982d8c4393d443dd732ed01 /src/pkg/http/server.go
parent66dd26e9673b458a36265d6e8878de20abf3ab8d (diff)
downloadgo-dc6f8321b11370a5b3dd2babd64c60228c274e78.tar.xz
http: add HandleFunc as shortcut to Handle(path, HandlerFunc(func))
R=rsc CC=golang-dev https://golang.org/cl/763042
Diffstat (limited to 'src/pkg/http/server.go')
-rw-r--r--src/pkg/http/server.go11
1 files changed, 11 insertions, 0 deletions
diff --git a/src/pkg/http/server.go b/src/pkg/http/server.go
index dff0d1746e..bd1d0a703f 100644
--- a/src/pkg/http/server.go
+++ b/src/pkg/http/server.go
@@ -524,10 +524,21 @@ func (mux *ServeMux) Handle(pattern string, handler Handler) {
}
}
+// HandleFunc registers the handler function for the given pattern.
+func (mux *ServeMux) HandleFunc(pattern string, handler func(*Conn, *Request)) {
+ mux.Handle(pattern, HandlerFunc(handler))
+}
+
// Handle registers the handler for the given pattern
// in the DefaultServeMux.
func Handle(pattern string, handler Handler) { DefaultServeMux.Handle(pattern, handler) }
+// HandleFunc registers the handler function for the given pattern
+// in the DefaultServeMux.
+func HandleFunc(pattern string, handler func(*Conn, *Request)) {
+ DefaultServeMux.HandleFunc(pattern, handler)
+}
+
// Serve accepts incoming HTTP connections on the listener l,
// creating a new service thread for each. The service threads
// read requests and then call handler to reply to them.