Commit Graph

3 Commits

Author SHA1 Message Date
4060f64b98 basic interactions work 2026-09-28 23:34:04 +06:00
4906ca7652 Add HTTP bridge so the CoAP server can be checked in a browser
Browsers speak HTTP over TCP and cannot open coap:// URLs, which made the
server awkward to try without the CLI client. The bridge accepts an ordinary
HTTP request, reissues it as CoAP over UDP, and maps the response code back
onto an HTTP status (the raw code is also returned in X-Coap-Code).

It serves a test console at / with a name field and a button per route, so
GET, POST, 4.04 and 4.05 can all be exercised by clicking.

The CoAP request logic moves from src/bin/client.rs into src/lib.rs so the
client and the bridge share one implementation.

The bridge is a development convenience: a small HTTP/1.1 subset with no
keep-alive, chunked bodies or TLS.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-05 10:01:44 +06:00
137b9d9547 Add CoAP-over-UDP hello server in Rust
A minimal CoAP (RFC 7252) server built on coap-lite for message encoding
and a tokio UdpSocket for transport. The socket, read loop and routing are
kept in src/main.rs rather than behind a framework.

Routes:
  GET  /hello[?name=X]  -> 2.05 "Hello, X!" (defaults to World)
  POST /hello           -> 2.01, name from a raw text or JSON body
  GET  /health          -> 2.05 status + uptime

Unknown paths return 4.04, known paths with the wrong method 4.05.

Includes a CLI client (src/bin/client.rs) for smoke tests and unit tests
covering the greeting, payload parsing and query decoding. Verified against
node-coap as an independent implementation to confirm wire compatibility.

The earlier Node.js prototype is kept under nodejs/ for reference.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
2026-09-03 10:28:24 +06:00