diff options
| author | Andrew Gerrand <adg@golang.org> | 2010-03-29 10:02:37 +1100 |
|---|---|---|
| committer | Andrew Gerrand <adg@golang.org> | 2010-03-29 10:02:37 +1100 |
| commit | 0f196a7914dd1d87a964e591e3cd73f88d7b59ad (patch) | |
| tree | 05f5c0debc4cafb109199630d8d55dbe343b0d05 | |
| parent | b5e9ad29d3c3ecd81cd7587d7f462083073266f1 (diff) | |
| download | golang-0f196a7914dd1d87a964e591e3cd73f88d7b59ad.tar.gz | |
http: add HandleFunc as shortcut to Handle(path, HandlerFunc(func))
R=rsc
CC=golang-dev
http://codereview.appspot.com/763042
| -rw-r--r-- | src/pkg/http/server.go | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/src/pkg/http/server.go b/src/pkg/http/server.go index dff0d1746..bd1d0a703 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. |
