A web framework for Guile https://docs.cbaines.net/safsaf/
  • Scheme 52.8%
  • Tree-sitter Query 44.8%
  • JavaScript 1%
  • Makefile 0.7%
  • M4 0.4%
  • Other 0.3%
Find a file
Repository files (latest commit first)
Filename Latest commit message Latest commit date
Christopher Baines f50a53cbe0 Update the pipelines
For changes in Guile Automate.
2026-09-27 11:37:50 +01:00
.automate Update the pipelines 2026-09-27 11:37:50 +01:00
.forgejo/workflows Add missing logo to website 2026-04-14 10:32:01 +03:00
build-aux Implement syntax highlighting in the HTML manual 2026-08-26 11:50:17 +01:00
doc Include the texinfo CSS 2026-09-20 19:44:08 +02:00
examples Add a mechanism to write routes to a port 2026-09-09 17:28:12 +01:00
safsaf Add a mechanism to write routes to a port 2026-09-09 17:28:12 +01:00
tests Add a mechanism to write routes to a port 2026-09-09 17:28:12 +01:00
.dir-locals.el Fix the with-exception-handler formatting 2026-08-06 16:17:42 +01:00
.gitignore Implement syntax highlighting in the HTML manual 2026-08-26 11:50:17 +01: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 Improve CLAUDE.md for NEWS entries 2026-09-09 09:53:27 +01:00
configure.ac Implement syntax highlighting in the HTML manual 2026-08-26 11:50:17 +01: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 Implement syntax highlighting in the HTML manual 2026-08-26 11:50:17 +01:00
Makefile.am Add a flash handler wrapper 2026-09-09 10:22:24 +01:00
NEWS Fix the NEWS file headers 2026-09-09 18:51:39 +01:00
pre-inst-env.in Initial commit 2026-04-13 14:24:19 +03:00
README.md Add a flash handler wrapper 2026-09-09 10:22:24 +01:00
safsaf.scm Improve module loading 2026-09-06 14:52:14 +01:00
STYLE.md Initial commit 2026-04-13 14:24:19 +03:00
VERSION Bump version to 0.5 2026-09-09 17:45:58 +01: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), flash messages, security headers, trailing-slash normalization, canonical host redirects, exception handling
  • Request helpers: form body parsing, multipart parsing, query strings, cookies
  • Response helpers: HTML/SHTML, 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

  • GNU Guile 3.0+
  • Guile Fibers (the scheduler everything runs on)
  • Guile Knots (web server, thread and resource pools; manual)
  • Guile Webutils (multipart parsing, cookie headers, signed-cookie sessions)
  • Guile JSON 4.x (the Scheme to JSON conversion the JSON response helpers use)
  • Guile Lib (htmlprag for SHTML, logging for the logger run-safsaf installs, md5 for ETags and asset fingerprints)
  • Guile Gcrypt (CSRF token randomness, SHA-1 and SHA-256 hashing)

The manual's Dependencies chapter says which of these an application imports itself and what each one is used for.

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

License

LGPL-3.0-or-later