Use HTMX-compatible HTML fragments on WebSocket, fix multi-connection

- WebSocket sends HTML fragments with id="price-display" instead of JSON
  for direct HTMX OOB swap on the client
- Switch from ring-undertow-adapter ws wrapper to raw Undertow WebSocket
  API (proxy) to fix single-connection limitation
- Keep JSON endpoint at /api/price/latest unchanged
- Update CLAUDE.md and README.md

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
2026-02-23 22:28:24 +01:00
co-authored by Claude Opus 4.6
parent 9283826ac4
commit 917b020be4
3 changed files with 56 additions and 30 deletions
+2 -2
View File
@@ -1,12 +1,12 @@
# btcdata
Bitcoin data backend service. Fetches BTC prices from Binance (WebSocket) and Kraken (HTTP polling), stores them in PostgreSQL, and exposes a JSON API with Server-Sent Events for live price streaming.
Bitcoin data backend service. Fetches BTC prices from Binance (WebSocket) and Kraken (HTTP polling), stores them in PostgreSQL, and exposes a JSON API with WebSocket for live price streaming.
## API
| Endpoint | Description |
|---|---|
| `GET /api/price/stream` | SSE stream — emits `price-update` events with JSON `{price, prev_price, recorded_at}` |
| `GET /api/price/ws` | WebSocket — sends HTML fragments with live price updates (HTMX-compatible) |
| `GET /api/price/latest` | Latest price as JSON |
| `GET /api/health` | Health check |