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.
1 package apiv1
3 import (
4 "net/http"
6 "code.secondbit.org/api.hg"
7 "code.secondbit.org/trout.hg"
8 "golang.org/x/net/context"
9 )
11 // GetRouter returns a trout Router that is configured to handle
12 // all the routes necessary to serve a devices API server.
13 func GetRouter(ctx context.Context) http.Handler {
14 var router trout.Router
15 router.Endpoint("/").Methods("POST").Handler(api.ContextWrapper(ctx, api.ContextHandler(handleCreateDevices)))
16 router.Endpoint("/").Methods("GET").Handler(api.ContextWrapper(ctx, api.ContextHandler(handleGetDevices)))
17 router.Endpoint("/{id}").Methods("GET").Handler(api.ContextWrapper(ctx, api.ContextHandler(handleGetDevices)))
18 // TODO(paddy): add the update handler
19 router.Endpoint("/{id}").Methods("PATCH").Handler(api.ContextWrapper(ctx, api.ContextHandler(nil)))
20 // TODO(paddy): add the delete handler
21 router.Endpoint("/").Methods("DELETE").Handler(api.ContextWrapper(ctx, api.ContextHandler(nil)))
22 router.Endpoint("/{id}").Methods("DELETE").Handler(api.ContextWrapper(ctx, api.ContextHandler(nil)))
24 return router
25 }