From 678d96e1eaa9b7b55206c7a570e3951601b27404 Mon Sep 17 00:00:00 2001 From: giles Date: Wed, 1 Apr 2026 14:24:35 +0000 Subject: [PATCH] handler-source reconstructs defhandler form instead of dumping dict Builds (defhandler name :path ... :method ... params body) from the handler dict fields and pretty-prints it with syntax highlighting. Co-Authored-By: Claude Opus 4.6 (1M context) --- sx/sx/data/helpers.sx | 24 ++++++++++++++++++++---- 1 file changed, 20 insertions(+), 4 deletions(-) diff --git a/sx/sx/data/helpers.sx b/sx/sx/data/helpers.sx index c296b7ee..e80ceb2b 100644 --- a/sx/sx/data/helpers.sx +++ b/sx/sx/data/helpers.sx @@ -25,14 +25,30 @@ (name) (let ((handler-key (str "handler:" name)) - (val + (hdef (cek-try (fn () (eval-expr (make-symbol handler-key))) (fn (err) nil)))) (if - (not (nil? val)) - (pretty-print val) - (str ";;; Handler not found: " name))))) + (nil? hdef) + (str ";;; Handler not found: " name) + (let + ((method (or (get hdef "method") "get")) + (path (get hdef "path")) + (csrf (get hdef "csrf")) + (returns (or (get hdef "returns") "element")) + (params (or (get hdef "params") (list))) + (body (get hdef "body"))) + (pretty-print + (list + (make-symbol "defhandler") + (make-symbol name) + :path path + :method (make-keyword method) + :csrf csrf + :returns returns + params + body))))))) (define _spec-dirs (list "spec" "web" "shared/sx/ref" "lib"))