Log route count on boot and no-match on route attempts
Shows "pages: N routes loaded" at startup and "sx:route no match (N routes) /path" when no route matches, so we can see if routes loaded and why matching fails. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
// =========================================================================
|
||||
|
||||
var NIL = Object.freeze({ _nil: true, toString: function() { return "nil"; } });
|
||||
var SX_VERSION = "2026-03-06T21:05:23Z";
|
||||
var SX_VERSION = "2026-03-06T21:10:17Z";
|
||||
|
||||
function isNil(x) { return x === NIL || x === null || x === undefined; }
|
||||
function isSxTruthy(x) { return x !== false && !isNil(x); }
|
||||
@@ -1927,7 +1927,7 @@ return forEach(function(form) { return (isSxTruthy((isSxTruthy(!isProcessed(form
|
||||
// try-client-route
|
||||
var tryClientRoute = function(pathname) { return (function() {
|
||||
var match = findMatchingRoute(pathname, _pageRoutes);
|
||||
return (isSxTruthy(isNil(match)) ? false : (isSxTruthy(get(match, "has-data")) ? (logInfo((String("sx:route server (has data) ") + String(pathname))), false) : (function() {
|
||||
return (isSxTruthy(isNil(match)) ? (logInfo((String("sx:route no match (") + String(len(_pageRoutes)) + String(" routes) ") + String(pathname))), false) : (isSxTruthy(get(match, "has-data")) ? (logInfo((String("sx:route server (has data) ") + String(pathname))), false) : (function() {
|
||||
var contentSrc = get(match, "content");
|
||||
var closure = sxOr(get(match, "closure"), {});
|
||||
var params = get(match, "params");
|
||||
@@ -2340,13 +2340,17 @@ callExpr.push(dictGet(kwargs, k)); } }
|
||||
// process-page-scripts
|
||||
var processPageScripts = function() { return (function() {
|
||||
var scripts = queryPageScripts();
|
||||
return forEach(function(s) { return (isSxTruthy(!isProcessed(s, "pages")) ? (markProcessed(s, "pages"), (function() {
|
||||
{ var _c = scripts; for (var _i = 0; _i < _c.length; _i++) { var s = _c[_i]; if (isSxTruthy(!isProcessed(s, "pages"))) {
|
||||
markProcessed(s, "pages");
|
||||
(function() {
|
||||
var text = domTextContent(s);
|
||||
return (isSxTruthy((isSxTruthy(text) && !isEmpty(trim(text)))) ? (function() {
|
||||
var pages = parse(text);
|
||||
return forEach(function(page) { return append_b(_pageRoutes, merge(page, {"parsed": parseRoutePattern(get(page, "path"))})); }, pages);
|
||||
})() : NIL);
|
||||
})()) : NIL); }, scripts);
|
||||
})();
|
||||
} } }
|
||||
return logInfo((String("pages: ") + String(len(_pageRoutes)) + String(" routes loaded")));
|
||||
})(); };
|
||||
|
||||
// boot-init
|
||||
|
||||
@@ -319,7 +319,8 @@
|
||||
(merge page
|
||||
{"parsed" (parse-route-pattern (get page "path"))})))
|
||||
pages))))))
|
||||
scripts))))
|
||||
scripts)
|
||||
(log-info (str "pages: " (len _page-routes) " routes loaded")))))
|
||||
|
||||
|
||||
;; --------------------------------------------------------------------------
|
||||
|
||||
@@ -543,7 +543,7 @@
|
||||
;; Only works for pages without :data dependencies.
|
||||
(let ((match (find-matching-route pathname _page-routes)))
|
||||
(if (nil? match)
|
||||
false
|
||||
(do (log-info (str "sx:route no match (" (len _page-routes) " routes) " pathname)) false)
|
||||
(if (get match "has-data")
|
||||
(do (log-info (str "sx:route server (has data) " pathname)) false)
|
||||
(let ((content-src (get match "content"))
|
||||
|
||||
Reference in New Issue
Block a user