1
0
Fork
You've already forked sigil-web
0
Web application framework for Sigil (routing, middleware, static files, cookies).
  • JavaScript 100%
Find a file
David Wilson 34f1f6e8c0
Some checks failed
ci/woodpecker/push/woodpecker Pipeline failed
Fix live-stream SSE endpoint 500 by passing an explicit broadcast handler
stream-events-handler called http-response/sse-broadcast while omitting the
broadcast handler positional, relying on it defaulting to identity. That
default only exists in the `. opts` form (sigil-http 0.16.7+). Releases
0.16.1-0.16.6 typed the handler as a required positional; omitting it (and
jumping straight to the on-connect: keyword) crashed the SSE connect with
"car: expected pair" - a 500 on GET /feed, most visible when the server runs
interpreted and loads one of those releases.
Pass `identity` explicitly. It is correct for every release: the hub carries
pre-formatted SSE strings so identity is the right handler, and the `. opts`
form accepts a leading procedure too. Bumps to 0.16.1 and adds a regression
test for the live-routes -> handler call contract.
2026年07月10日 14:27:29 +03:00
assets/sigil-web/js Fix ui-update morph: morph the element itself (outerHTML), not innerHTML 2026年07月05日 21:23:30 +03:00
docs Resolve [DW] doc review comments; rename flash-message -> sg-flash-message 2026年07月06日 14:34:54 +03:00
src/sigil Fix live-stream SSE endpoint 500 by passing an explicit broadcast handler 2026年07月10日 14:27:29 +03:00
test Fix live-stream SSE endpoint 500 by passing an explicit broadcast handler 2026年07月10日 14:27:29 +03:00
.gitignore Untrack .sigil/deps/ symlinks; ignore .sigil/ 2026年04月26日 08:31:01 +03:00
.woodpecker.yml Bump CI pin to sigil v0.14.3 2026年04月26日 19:01:42 +03:00
CHANGELOG.md Fix live-stream SSE endpoint 500 by passing an explicit broadcast handler 2026年07月10日 14:27:29 +03:00
dev-redirects.sgl Convert to standalone package 2026年03月31日 10:23:09 +03:00
package.sgl Fix live-stream SSE endpoint 500 by passing an explicit broadcast handler 2026年07月10日 14:27:29 +03:00
README.md Migrate to 0.9.1 transitive deps with version ranges and lockfile 2026年04月01日 12:10:59 +03:00
sigil.lock Bump sigil-http pin to ^0.18.0 for serve-file Range support 2026年07月10日 13:12:22 +03:00

sigil-web

Web application framework for Sigil. Provides routing, middleware, static file serving, cookies, and a server-driven UI library for building interactive web applications.

Usage

Routing

(import (sigil web routes))
;; Define routes with pattern matching
(define app
 (router
 (route GET "/" home-handler)
 (route GET "/users/:id" user-handler)
 (route POST "/api/login" login-handler)
 (route ANY "/static/*path" static-handler)))
;; Extract path parameters in handlers
(define (user-handler request)
 (let ((id (path-param request "id")))
 ...))

Middleware

(import (sigil web middleware))
;; Compose middleware around a handler
(define handler
 (wrap-middleware app
 (cors-middleware '("*"))
 (content-type-middleware "text/html")
 (not-found-middleware)))
;; Or use the chain style
(define handler
 (chain app
 (with-cors "*")
 (with-content-type "text/html")
 (with-not-found)))

Static Files

(import (sigil web static))
;; Serve files from a directory with MIME type detection
(define static-handler (make-static-handler "public/"))

Cookies

(import (sigil web cookies))
;; Read cookies from a request
(cookie-ref request "session_id")
;; Set a cookie on a response
(set-cookie response "session_id" "abc123"
 '((path . "/") (http-only . #t)))

Server-Driven UI

(import (sigil web ui))
;; Send SSE events for real-time updates
(sse-morph target: "#chat" mode: "append"
 content: `(div (@ (class "msg")) "Hello!"))
;; Return HTML with merge headers
(sigil-ui-response target: "#results" mode: "inner"
 content: `(ul ,@(map render-item items)))

Live Development

(import (sigil web dev))
(define dev (make-dev-broadcast))
;; Wire (dev-sse-handler) into your router at /__dev/events
;; Then trigger browser refresh:
(dev-reload!)

Modules

  • (sigil web routes) -- path-based routing with named and splat parameters
  • (sigil web middleware) -- composable middleware (CORS, content-type, not-found)
  • (sigil web static) -- static file serving with directory traversal protection
  • (sigil web cookies) -- cookie parsing and setting
  • (sigil web ui) -- server-driven hypermedia (SSE morphing, forms, modals, data tables)
  • (sigil web dev) -- live development broadcast and error overlay

Dependencies

  • sigil-stdlib
  • sigil-http
  • sigil-sxml
  • sigil-nrepl

Build

sigil deps install
sigil build
sigil test

License

BSD-3-Clause