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%
Find a file
Christopher Baines d0cb074ed1
All checks were successful
/ test (push) Successful in 19s
Add more options to the session handler wrapper
2026-05-03 23:44:54 +01:00
.forgejo/workflows Add missing logo to website 2026-04-14 10:32:01 +03:00
build-aux Initial commit 2026-04-13 14:24:19 +03:00
doc Add Server-Sent Events functionality 2026-04-19 14:03:42 +01:00
examples Add more options to the session handler wrapper 2026-05-03 23:44:54 +01:00
safsaf Add more options to the session handler wrapper 2026-05-03 23:44:54 +01:00
tests Add more options to the session handler wrapper 2026-05-03 23:44:54 +01:00
.dir-locals.el Initial commit 2026-04-13 14:24:19 +03:00
.gitignore Initial commit 2026-04-13 14:24:19 +03:00
AUTHORS Initial commit 2026-04-13 14:24:19 +03:00
bootstrap.sh Initial commit 2026-04-13 14:24:19 +03:00
CLAUDE.md Initial commit 2026-04-13 14:24:19 +03:00
configure.ac Initial commit 2026-04-13 14:24:19 +03:00
COPYING Initial commit 2026-04-13 14:24:19 +03:00
COPYING.LESSER Initial commit 2026-04-13 14:24:19 +03:00
guile.am Initial commit 2026-04-13 14:24:19 +03:00
guix-dev.scm Initial commit 2026-04-13 14:24:19 +03:00
Makefile.am Add initial internationalisation support 2026-04-19 14:06:59 +01:00
NEWS Initial commit 2026-04-13 14:24:19 +03:00
pre-inst-env.in Initial commit 2026-04-13 14:24:19 +03:00
README.md Add initial internationalisation support 2026-04-19 14:06:59 +01:00
safsaf.scm Add #:parallelism to run-safsaf 2026-04-26 22:29:32 +01:00
STYLE.md Initial commit 2026-04-13 14:24:19 +03:00
VERSION Initial commit 2026-04-13 14:24:19 +03:00

Safsaf

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-stream responses with keepalives and Last-Event-ID replay
  • Parameter parsing: declarative param specs with built-in processors, CSRF integration, and error inspection
  • Internationalisation: gettext-style t / tn helpers backed by an in-Scheme catalog loaded from .po files, with a locale handler wrapper that selects per-request from route params, cookie, or Accept-Language

Wishlist

  • WebSockets support

Other Guile web frameworks

Dependencies

A Guix development environment is provided via guix-dev.scm and .envrc (direnv).

License

LGPL-3.0-or-later