routes

package
v0.0.0-...-2387267 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jun 9, 2022 License: MIT Imports: 8 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

View Source
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

func GetDevice

func GetDevice(w http.ResponseWriter, r *http.Request)

GetDevice handles GET requests to /devices/<id> and returns a JSON structure describing the requested device if it was found, else it returns a `404 NOT FOUND` error

func GetRoom

func GetRoom(w http.ResponseWriter, r *http.Request)

GetRoom handles all GET requests to /rooms/<id> and either returns a json structure describing the room or a `Not Found` error, if the room can't be found in the database

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL