go run main/main.go
Copy config.example.json
to config.json
.
The example has the following content:
{
"port": 5000,
"resources": {
"test": {
"name": "Test Resource",
"min": 0,
"max": 3
}
}
}
The server will listen on port 5000
.
There is only one resource configured.
It has the id test
.
When requesting the status over the API, use this id.
It's name is Test Resource
and it's status has to be in the range between 0
and 3
.
gow run main/main.go
Adds automatic reloads.
If gow
is not installed:
go install github.com/mitranim/gow@latest
Returns all registered resources. For example:
{
"resources": [
"bikebox1",
"garage1"
]
}
Returns the status of the resource. For example:
{
"name": "Test Resource",
"num": 1
}
To request an update of the resource status. The request must be in the following format:
{
"delta": -1
}
It then returns the updated status of the resource (see above)