]> Cypherpunks repositories - gostls13.git/commitdiff
http: add HandleFunc as shortcut to Handle(path, HandlerFunc(func))
authorAndrew Gerrand <adg@golang.org>
Sun, 28 Mar 2010 23:02:37 +0000 (10:02 +1100)
committerAndrew Gerrand <adg@golang.org>
Sun, 28 Mar 2010 23:02:37 +0000 (10:02 +1100)
R=rsc
CC=golang-dev
https://golang.org/cl/763042

src/pkg/http/server.go

index dff0d1746e4df713f358bf063a841d2f9ba7eaff..bd1d0a703fd227a93af377952122d81c5348790b 100644 (file)
@@ -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.