ducky/devices
ducky/devices/apiv1/endpoints.go
Update trout to fix routing bug. Update to tip on trout to fix the routing bug that was causing us such issues. See the commit message of trout at 3df515f0cec5 for more details.
| paddy@15 | 1 package apiv1 |
| paddy@15 | 2 |
| paddy@15 | 3 import ( |
| paddy@15 | 4 "net/http" |
| paddy@15 | 5 |
| paddy@15 | 6 "code.secondbit.org/api.hg" |
| paddy@15 | 7 "code.secondbit.org/trout.hg" |
| paddy@15 | 8 "golang.org/x/net/context" |
| paddy@15 | 9 ) |
| paddy@15 | 10 |
| paddy@15 | 11 // GetRouter returns a trout Router that is configured to handle |
| paddy@15 | 12 // all the routes necessary to serve a devices API server. |
| paddy@15 | 13 func GetRouter(ctx context.Context) http.Handler { |
| paddy@15 | 14 var router trout.Router |
| paddy@15 | 15 router.Endpoint("/").Methods("POST").Handler(api.ContextWrapper(ctx, api.ContextHandler(handleCreateDevices))) |
| paddy@18 | 16 router.Endpoint("/").Methods("GET").Handler(api.ContextWrapper(ctx, api.ContextHandler(handleGetDevices))) |
| paddy@18 | 17 router.Endpoint("/{id}").Methods("GET").Handler(api.ContextWrapper(ctx, api.ContextHandler(handleGetDevices))) |
| paddy@18 | 18 // TODO(paddy): add the update handler |
| paddy@18 | 19 router.Endpoint("/{id}").Methods("PATCH").Handler(api.ContextWrapper(ctx, api.ContextHandler(nil))) |
| paddy@18 | 20 // TODO(paddy): add the delete handler |
| paddy@18 | 21 router.Endpoint("/").Methods("DELETE").Handler(api.ContextWrapper(ctx, api.ContextHandler(nil))) |
| paddy@18 | 22 router.Endpoint("/{id}").Methods("DELETE").Handler(api.ContextWrapper(ctx, api.ContextHandler(nil))) |
| paddy@15 | 23 |
| paddy@15 | 24 return router |
| paddy@15 | 25 } |