moonhttp — the HTTP family for MoonBit: WebSocket framing, Server-Sent Events, and multipart and URL-encoded bodies, each a package of its own.
// An event stream, one frame at a time.
@sse.Event::new(data="{\"seq\":1}", kind=Some("tick"), id=Some("1")).encode()
@sse.decode(received[:])
// A posted form, whichever way the browser encoded it.
let form = @mime.parse(body[:], content_type[:])
form.field("name")
form.file("avatar")| Package | What | Specification |
|---|---|---|
| sse | Server-Sent Events, both directions | WHATWG HTML, the event-stream format |
| mime | multipart/form-data and application/x-www-form-urlencoded | RFC 7578, WHATWG URL §5.1 |
moon add moonbitstack/moonhttpInstall
Download zipmoonhttp — the HTTP family for MoonBit: WebSocket framing, Server-Sent Events, and multipart and URL-encoded bodies, each a package of its own.