A web framework for Guile
https://cbaines.codeberg.page/safsaf/
- Scheme 75.2%
- Tree-sitter Query 22%
- Makefile 1.1%
- M4 0.9%
- Shell 0.8%
|
|
||
|---|---|---|
| .forgejo/workflows | ||
| build-aux | ||
| doc | ||
| examples | ||
| safsaf | ||
| tests | ||
| .dir-locals.el | ||
| .gitignore | ||
| AUTHORS | ||
| bootstrap.sh | ||
| CLAUDE.md | ||
| configure.ac | ||
| COPYING | ||
| COPYING.LESSER | ||
| guile.am | ||
| guix-dev.scm | ||
| Makefile.am | ||
| NEWS | ||
| pre-inst-env.in | ||
| README.md | ||
| safsaf.scm | ||
| STYLE.md | ||
| VERSION | ||
Safsaf
A web framework for GNU Guile, using Guile Fibers and the Guile Knots web server.
Developed based off of the Guix Data Service and Nar Herder codebases, written using Claude Code running Claude Opus 4.6.
Quick Example
(use-modules (safsaf)
(safsaf router)
(safsaf response-helpers))
(define routes
(list
(route 'GET '() (lambda (request body-port)
(text-response "Hello, world!")))
(route '* '* (lambda (request body-port)
(not-found-response)))))
(run-safsaf routes #:port 8080)
Design
Safsaf aims for functional over imperitive configuration and to be minimal but very extensible.
Suspendable ports in Guile plus Guile Fibers is used both for Safsaf internals, but should also be used for user applications where possible and suitable.
Features
- Request router with parameterised segments, wildcards, nested
groups, and reverse routing (
path-for) - Handler wrappers (middleware) applied per-route or per-group via
wrap-routes - Included handler wrappers: logging, CORS, CSRF protection, sessions (signed cookies), security headers, trailing-slash normalization, exception handling
- Request helpers: form body parsing, multipart parsing, query strings, cookies
- Response helpers: HTML/SXML, JSON, redirects, plain text, static
files with
Last-Modified/Cache-Control - Server-Sent Events (SSE): streaming
text/event-streamresponses with keepalives andLast-Event-IDreplay - Parameter parsing: declarative param specs with built-in processors, CSRF integration, and error inspection
- Internationalisation: gettext-style
t/tnhelpers backed by an in-Scheme catalog loaded from.pofiles, with alocalehandler wrapper that selects per-request from route params, cookie, orAccept-Language
Wishlist
- WebSockets support
Other Guile web frameworks
- GNU Artanis https://artanis.dev/
- schingle https://github.com/petelliott/schingle
Dependencies
- GNU Guile 3.0+
- Guile Knots (web server, resource pools)
- Guile Webutils (multipart, cookies, sessions)
- Guile JSON 4.x
- Guile Lib (htmlprag, logging)
A Guix development environment is provided via guix-dev.scm and
.envrc (direnv).
License
LGPL-3.0-or-later