| 1 | package godo |
| 2 | |
| 3 | // Handler is the interface which all task handlers eventually implement. |
| 4 | type Handler interface { |
| 5 | Handle(*Context) |
| 6 | } |
| 7 | |
| 8 | // // HandlerFunc is Handler adapter. |
| 9 | // type handlerFunc func() error |
| 10 | |
| 11 | // // Handle implements Handler. |
| 12 | // func (f handlerFunc) Handle(*Context) error { |
| 13 | // return f() |
| 14 | // } |
| 15 | |
| 16 | // // VoidHandlerFunc is a Handler adapter. |
| 17 | // type voidHandlerFunc func() |
| 18 | |
| 19 | // // Handle implements Handler. |
| 20 | // func (v voidHandlerFunc) Handle(*Context) error { |
| 21 | // v() |
| 22 | // return nil |
| 23 | // } |
| 24 | |
| 25 | // // ContextHandlerFunc is a Handler adapter. |
| 26 | // type contextHandlerFunc func(*Context) error |
| 27 | |
| 28 | // // Handle implements Handler. |
| 29 | // func (c contextHandlerFunc) Handle(ctx *Context) error { |
| 30 | // return c(ctx) |
| 31 | // } |
| 32 | |
| 33 | // HandlerFunc is a Handler adapter. |
| 34 | type HandlerFunc func(*Context) |
| 35 | |
| 36 | // Handle implements Handler. |
| 37 | func (f HandlerFunc) Handle(ctx *Context) { |
| 38 | f(ctx) |
| 39 | } |