1
0
mirror of https://github.com/golang/go synced 2024-11-13 17:30:24 -07:00

take advantage of methods on funcs

R=r
DELTA=14  (0 added, 13 deleted, 1 changed)
OCL=24458
CL=24470
This commit is contained in:
Russ Cox 2009-02-05 15:09:08 -08:00
parent aab26a5248
commit 7a3877aa0c

View File

@ -220,24 +220,11 @@ func (c *Conn) Hijack() (fd io.ReadWriteClose, buf *bufio.BufReadWrite, err *os.
return; return;
} }
// Adapter: can use RequestFunction(f) as Handler // Adapter: can use HandlerFunc(f) as Handler
type handlerFunc struct {
f func(*Conn, *Request)
}
func (h handlerFunc) ServeHTTP(c *Conn, req *Request) {
h.f(c, req)
}
func HandlerFunc(f func(*Conn, *Request)) Handler {
return handlerFunc{f}
}
/* simpler version of above, not accepted by 6g:
type HandlerFunc func(*Conn, *Request) type HandlerFunc func(*Conn, *Request)
func (f HandlerFunc) ServeHTTP(c *Conn, req *Request) { func (f HandlerFunc) ServeHTTP(c *Conn, req *Request) {
f(c, req); f(c, req);
} }
*/
// Helper handlers // Helper handlers