api: optimize status endpoint payload and caching

This commit is contained in:
2026-06-07 19:04:30 -06:00
parent a721f6b539
commit 512a1aa302
3 changed files with 166 additions and 1 deletions
+40 -1
View File
@@ -149,7 +149,12 @@ Returns API and feature discovery data for clients.
Returns complete controller status.
Top-level response:
Example requests:
GET /api/v1/status
GET /api/v1/status?fields=battery,relays,temps
Top-level full response:
```json
{
@@ -166,6 +171,40 @@ Top-level response:
}
```
#### Optional `fields` query parameter
`GET /api/v1/status` accepts an optional comma-separated `fields` query parameter.
Valid fields:
battery, temps, relays, vehicle, network, alarms, system, config
If `fields` is omitted, the endpoint returns the complete status payload.
If an unknown field is requested, the Cargo ESP32 returns HTTP `400`:
{
"ok": false,
"error": "invalid_field",
"details": ["Unknown field 'xyz'"]
}
#### HTTP caching
`GET /api/v1/status` returns these cache validation headers:
ETag
Last-Modified
Cache-Control: no-cache
Clients may revalidate with `If-None-Match` or `If-Modified-Since`.
If the selected status payload has not changed, the Cargo ESP32 returns:
HTTP/1.1 304 Not Modified
A `304` response has no JSON body.
### battery
```json