Commit 7a3877aa authored by Russ Cox's avatar Russ Cox

take advantage of methods on funcs

R=r
DELTA=14  (0 added, 13 deleted, 1 changed)
OCL=24458
CL=24470
parent aab26a52
......@@ -220,24 +220,11 @@ func (c *Conn) Hijack() (fd io.ReadWriteClose, buf *bufio.BufReadWrite, err *os.
return;
}
// Adapter: can use RequestFunction(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:
// Adapter: can use HandlerFunc(f) as Handler
type HandlerFunc func(*Conn, *Request)
func (f HandlerFunc) ServeHTTP(c *Conn, req *Request) {
f(c, req);
}
*/
// Helper handlers
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment