mirror of
https://github.com/golang/go
synced 2024-11-12 04:50:21 -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:
parent
aab26a5248
commit
7a3877aa0c
@ -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
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user