add device api endpoints

This commit is contained in:
SowinskiBraeden committed 2022-09-28 14:09:39 -07:00
1 parent 1bc9618690
commit 4f4438b4b2
2 files changed
+11 -4

No files matched your search

+7
View File
@@ -29,6 +29,7 @@ type App struct {
func (a *App) New() *mux.Router {
r := mux.NewRouter()
cow := Cow{DB: databases.NewCowDatabase(a.dbHelper)}
device := Device{DB: databases.NewDeviceDatabase(a.dbHelper)}
// healthcheck
r.HandleFunc("/health", healthCheckHandler)
@@ -41,6 +42,12 @@ func (a *App) New() *mux.Router {
apiCreate.Handle("/cows/new", api.Middleware(http.HandlerFunc(cow.NewCowHandler))).Methods("POST")
apiCreate.Handle("/cows/update/{cow_id}", api.Middleware(http.HandlerFunc(cow.UpdateCowHandler))).Methods("POST") // By Object ID not CowCode
apiCreate.Handle("/device/{device_id}", api.Middleware(http.HandlerFunc(device.DeviceByIDHandler))).Methods("GET")
apiCreate.Handle("/devices", api.Middleware(http.HandlerFunc(device.DeviceHandler))).Methods("GET")
apiCreate.Handle("/devices", api.Middleware(http.HandlerFunc(device.DeviceHandlerQuery))).Methods("POST")
apiCreate.Handle("/devices/new", api.Middleware(http.HandlerFunc(device.NewDeviceHandler))).Methods("POST")
apiCreate.Handle("/devices/update/{device_id}", api.Middleware(http.HandlerFunc(device.UpdateDeviceHandler))).Methods("POST")
return r
}