Implement filter POSTing and GETting. (#296)

* Implement filter POSTing and GETting.

Signed-off-by: Jan Christian Grünhage <jan.christian@gruenhage.xyz>

* Add missing '}' typo introduced during merge

* Still trying to fix that merge...

* Fix linting
This commit is contained in:
Erik Johnston 2017-10-10 14:28:49 +01:00 committed by GitHub
parent e9314e5b30
commit f6bda82366
5 changed files with 278 additions and 16 deletions

View file

@ -189,23 +189,18 @@ func Setup(
}),
).Methods("GET")
r0mux.Handle("/user/{userID}/filter",
common.MakeExternalAPI("make_filter", func(req *http.Request) util.JSONResponse {
// TODO: Persist filter and return filter ID
return util.JSONResponse{
Code: 200,
JSON: struct{}{},
}
r0mux.Handle("/user/{userId}/filter",
common.MakeAuthAPI("put_filter", deviceDB, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
vars := mux.Vars(req)
return writers.PutFilter(req, device, accountDB, vars["userId"])
}),
).Methods("POST", "OPTIONS")
r0mux.Handle("/user/{userID}/filter/{filterID}",
common.MakeExternalAPI("filter", func(req *http.Request) util.JSONResponse {
// TODO: Retrieve filter based on ID
return util.JSONResponse{
Code: 200,
JSON: struct{}{},
}
r0mux.Handle("/user/{userId}/filter/{filterId}",
common.MakeAuthAPI("get_filter", deviceDB, func(req *http.Request, device *authtypes.Device) util.JSONResponse {
vars := mux.Vars(req)
return readers.GetFilter(req, device, accountDB, vars["userId"], vars["filterId"])
}),
).Methods("GET")