[ANN] Schematra 0.7.0: now with WebSockets

Rolando Abarca via Chicken-users <[email protected]> Sun, 31 May 2026 21:38:33 -0700
Newsgroups gmane.lisp.scheme.chicken
Message-ID <CADnrc4D7boo_B14Q_y2HOmHw8M2UTNz9j_FX+797qRD_Mktf4w@mail.gmail.com>
--0000000000000e3eb2065329c5ea
Content-Type: text/plain; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

Hi all,

I just released 0.7.0 of Schematra (https://github.com/schematra/schematra)=
,
the Sinatra-inspired web framework for CHICKEN. The headline is native
WebSocket support, using the same route syntax as the rest of the framework=
:

  (import schematra schematra.ws)

  (websocket "/echo"
    (on-open  (send-text "welcome"))
    (on-text message (send-text (string-append "you said: " message)))
    (on-close code reason (void)))

(current-websocket) is the connection inside a handler =E2=80=94 store it i=
n a
registry to broadcast, share it across threads, force-close from outside
(closes the input port so the read loop unblocks immediately). Sends are
mutex-guarded per connection.

The protocol bits (handshake, frame parser/writer, masking, control frames,
fragmentation, close handshake) are written from scratch against RFC 6455.
I run the Autobahn TestSuite (
https://github.com/crossbario/autobahn-testsuite) on every release, with a
current pass rate of 98.3% (296 of 301 strict) across framing,
fragmentation, UTF-8, close handling, and the =C2=A79 stress cases (16 MiB
single frames, 200k fragments per message). permessage-deflate is the
obvious gap, which I'm addressing in the next minor version.

0.7.0 also splits the egg into smaller extensions (schematra, schematra.ws,
schematra.utils) so plain HTTP apps don't pull the WebSocket dependencies
(base64, simple-sha1, etc.). SSE is now built on the same long-connection
primitives WebSockets use (current-long-connection, start-long-connection!,
and port accessors are exported from schematra), so you can build other
long-lived protocols on the same plumbing. SSE responses also propagate
Set-Cookie now (was silently dropping them), and "csi -s app.scm" blocks on
schematra-start instead of falling off the end of the script.

Installable the usual way:

  chicken-install schematra

I also publish a Docker image at ghcr.io/schematra/schematra (tagged :0.7.1
and :latest) with CHICKEN, all dependencies, and the schematra / chiccup /
schematra-session / schematra-csrf / oauthtoothy eggs preinstalled. You
could use it as a FROM base for your own app, saves the CHICKEN + egg
compile time on every build, but please be aware that it's not meant to be
a production image, it's mostly a way to quickly run schematra or other
CHICKEN scheme code.

Links:
- Repo: https://github.com/schematra/schematra
- Release notes: https://schematra.com/blog/whats-new-in-schematra-0-7
- Multi-client chat demo: examples/websocket-demo.scm

Feedback and bug reports welcome.

Cheers,
Rolando

--0000000000000e3eb2065329c5ea
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div>Hi all,<br><br>I just released 0.7.0 of Schematra (<a=
 href=3D"https://github.com/schematra/schematra">https://github.com/schemat=
ra/schematra</a>), the Sinatra-inspired web framework for CHICKEN. The head=
line is native WebSocket support, using the same route syntax as the rest o=
f the framework:<br><br>=C2=A0 (import schematra <a href=3D"http://schematr=
a.ws">schematra.ws</a>)<br><br>=C2=A0 (websocket &quot;/echo&quot;<br>=C2=
=A0 =C2=A0 (on-open =C2=A0(send-text &quot;welcome&quot;))<br>=C2=A0 =C2=A0=
 (on-text message (send-text (string-append &quot;you said: &quot; message)=
))<br>=C2=A0 =C2=A0 (on-close code reason (void)))<br><br>(current-websocke=
t) is the connection inside a handler =E2=80=94 store it in a registry to b=
roadcast, share it across threads, force-close from outside (closes the inp=
ut port so the read loop unblocks immediately). Sends are mutex-guarded per=
 connection.<br><br>The protocol bits (handshake, frame parser/writer, mask=
ing, control frames, fragmentation, close handshake) are written from scrat=
ch against RFC 6455. I run the Autobahn TestSuite (<a href=3D"https://githu=
b.com/crossbario/autobahn-testsuite">https://github.com/crossbario/autobahn=
-testsuite</a>) on every release, with a current pass rate of 98.3% (296 of=
 301 strict) across framing, fragmentation, UTF-8, close handling, and the =
=C2=A79 stress cases (16 MiB single frames, 200k fragments per message). pe=
rmessage-deflate is the obvious gap, which I&#39;m addressing in the next m=
inor version.<br><br>0.7.0 also splits the egg into smaller extensions (sch=
ematra, <a href=3D"http://schematra.ws">schematra.ws</a>, schematra.utils) =
so plain HTTP apps don&#39;t pull the WebSocket dependencies (base64, simpl=
e-sha1, etc.). SSE is now built on the same long-connection primitives WebS=
ockets use (current-long-connection, start-long-connection!, and port acces=
sors are exported from schematra), so you can build other long-lived protoc=
ols on the same plumbing. SSE responses also propagate Set-Cookie now (was =
silently dropping them), and &quot;csi -s app.scm&quot; blocks on schematra=
-start instead of falling off the end of the script.<br><br>Installable the=
 usual way:<br><br>=C2=A0 chicken-install schematra<br><br>I also publish a=
 Docker image at <a href=3D"http://ghcr.io/schematra/schematra">ghcr.io/sch=
ematra/schematra</a> (tagged :0.7.1 and :latest) with CHICKEN, all dependen=
cies, and the schematra / chiccup / schematra-session / schematra-csrf / oa=
uthtoothy eggs preinstalled. You could use it as a FROM base for your own a=
pp, saves the CHICKEN + egg compile time on every build, but please be awar=
e that it&#39;s not meant to be a production image, it&#39;s mostly a way t=
o quickly run schematra or other CHICKEN scheme code.<br><br>Links:<br>- Re=
po: <a href=3D"https://github.com/schematra/schematra">https://github.com/s=
chematra/schematra</a><br>- Release notes: <a href=3D"https://schematra.com=
/blog/whats-new-in-schematra-0-7">https://schematra.com/blog/whats-new-in-s=
chematra-0-7</a><br>- Multi-client chat demo: examples/websocket-demo.scm<b=
r><br>Feedback and bug reports welcome.<br><br>Cheers,<br>Rolando<br></div>=
</div>

--0000000000000e3eb2065329c5ea--