Open ssfrr opened 10 years ago
What do you think about this approach: including a list of possible parameters in the response alongside the href. I played around with the idea on this branch:
https://github.com/kkleidal/chain-api/commit/dbfae46a913325baa16dc1283e31eeb744263356
Example output (I didn't actually define any params for the resource types shown):
{
"building": "",
"room": "",
"floor": "",
"description": "",
"_links": {
"ch:site": {
"href": "http://127.0.0.1:8080/sites/1",
"params": [],
"title": "MIT Media Lab"
},
"curies": [
{
"href": "http://chain-api.media.mit.edu/rels/{rel}",
"name": "ch",
"templated": true
}
],
"self": {
"href": "http://127.0.0.1:8080/devices/1",
"params": []
},
"ch:websocketStream": {
"href": "ws://127.0.0.1:8080/ws/device-1",
"title": "Websocket Stream"
},
"ch:sensors": {
"href": "http://127.0.0.1:8080/sensors/?device_id=1",
"params": [],
"title": "Sensors"
},
"editForm": {
"href": "http://127.0.0.1:8080/devices/1/edit",
"title": "Edit Device"
}
},
"name": "example"
}
for instance, when requesting sensor data the user can provide a start and end timestamp, but currently the server does not tell the client which parameters are available.