Documentation ¶
Index ¶
- Variables
- func AddDevice(w http.ResponseWriter, r *http.Request)
- func AddRoom(w http.ResponseWriter, r *http.Request)
- func AllDevices(w http.ResponseWriter, r *http.Request)
- func AllRooms(w http.ResponseWriter, r *http.Request)
- func DeleteDevice(w http.ResponseWriter, r *http.Request)
- func DeleteRoom(w http.ResponseWriter, r *http.Request)
- func GetDevice(w http.ResponseWriter, r *http.Request)
- func GetRoom(w http.ResponseWriter, r *http.Request)
Constants ¶
This section is empty.
Variables ¶
var Database *sql.DB
Database defines a new shared postgres instance, that is defined in main package's main() method
Functions ¶
func AddDevice ¶
func AddDevice(w http.ResponseWriter, r *http.Request)
AddDevice handles POST requests to /devices and returns a JSON structure describing the added device if it's successfully been inserted into the database
func AddRoom ¶
func AddRoom(w http.ResponseWriter, r *http.Request)
AddRoom trys to inserts a new room to the database instance defined in the Database variable
func AllDevices ¶
func AllDevices(w http.ResponseWriter, r *http.Request)
AllDevices handles GET requests to /devices and returns a JSON structure describing all devices in the database
func AllRooms ¶
func AllRooms(w http.ResponseWriter, r *http.Request)
AllRooms handles all GET /rooms and handles them accordingly
func DeleteDevice ¶
func DeleteDevice(w http.ResponseWriter, r *http.Request)
DeleteDevice handles DELETE requests to /devices/<id> and returns a `204 NO CONTENT` response if it was removed successfully, else it returns a `404 NOT FOUND` error
func DeleteRoom ¶
func DeleteRoom(w http.ResponseWriter, r *http.Request)
DeleteRoom handles all DELETE requests to /rooms/<id> and return either a `404 NOT FOUND` if the room does not exist or a 204 response if it's been deleted successfully
Types ¶
This section is empty.