From e1b711a7bed7858ee9bda75ae2d720a51a58f591 Mon Sep 17 00:00:00 2001 From: Daniel Covington Date: Fri, 10 Jul 2026 07:12:01 -0400 Subject: [PATCH] Isolate Routes --- CLAUDE.md | 26 ++++++++++++++------------ Core/Bootstrap.asp | 8 +++----- Core/Routes.asp | 5 +++++ 3 files changed, 22 insertions(+), 17 deletions(-) create mode 100644 Core/Routes.asp diff --git a/CLAUDE.md b/CLAUDE.md index 185e9c9..90a127e 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -101,14 +101,15 @@ reaches `IncludeAll.asp` with one. Add a new `Core/*.asp` class's `#include` lin web root" reason as everything else in `Core/` — not everything there is a reusable service. Alongside `IncludeAll.asp` (loads class definitions), `Core/Bootstrap.asp` is the actual construction/wiring step that used to live directly in `Default.asp`: it sets `Response.Buffer`/`ContentType`, `Dim`s every -page-level variable, `New`s up `App`/`ClockService`/`HttpRequest`/`Router`/`Dispatcher`, registers -routes and the `clockService`, binds the request, and calls `Boot`. Both are included right after each -other from `Default.asp` (`IncludeAll.asp` first, since `Bootstrap.asp`'s `New App` etc. need the class -definitions already loaded). **`Bootstrap.asp` turns `On Error Resume Next` on and deliberately leaves -it on** — `Default.asp`'s `Match`/`Dispatch` calls run under that same error-handling mode before -`Default.asp` itself checks `Err.Number` and calls `On Error Goto 0`. This works because `#include` -(and this nested pair of them) all splice into one compiled script, same as everywhere else in this -file — but it means you can't understand `Default.asp`'s error handling by reading `Default.asp` alone. +page-level variable, `New`s up `App`/`ClockService`/`HttpRequest`/`Router`/`Dispatcher`, includes +`Core/Routes.asp` to register all routes, then registers the `clockService`, binds the request, and +calls `Boot`. Both are included right after each other from `Default.asp` (`IncludeAll.asp` first, +since `Bootstrap.asp`'s `New App` etc. need the class definitions already loaded). **`Bootstrap.asp` +turns `On Error Resume Next` on and deliberately leaves it on** — `Default.asp`'s `Match`/`Dispatch` +calls run under that same error-handling mode before `Default.asp` itself checks `Err.Number` and calls +`On Error Goto 0`. This works because `#include` (and this nested pair of them) all splice into one +compiled script, same as everywhere else in this file — but it means you can't understand `Default.asp`'s +error handling by reading `Default.asp` alone. **Front controller.** `Public/web.config` rewrites every request that isn't a real file or directory to `Public/Default.asp` (preserving the query string). `Default.asp` is therefore the single entry @@ -118,8 +119,9 @@ both live in the two `Core/` includes above: ``` Default.asp ' loads every Core/*.asp class definition - ' New's + wires everything, AddRoute's, Binds, Boots, - ' and leaves On Error Resume Next switched on + ' New's + wires everything, Binds, Boots, + ' registers all AddRoute's (included by Bootstrap.asp) + ' leaves On Error Resume Next switched on → oRouter.Match(oApplication.Route) ' -> Dictionary{ControllerName, Params} or Nothing → oDispatcher.Dispatch app, routeMatch, controllerKey, oController ' ByRef outputs - see Dispatcher below → check Err.Number, then On Error Goto 0 ' closes out the Resume Next opened in Bootstrap.asp @@ -140,7 +142,7 @@ for where matching a key turns into an actual running controller. `id`), and two patterns that only differ in segment count can safely map to the same controller — they never both match the same request, since `Match` requires an exact segment-count match before it even looks at individual segments (`/greet/{name}` and `/greet/{name}/{id}` for `Greet` is the live example: -`Bootstrap.asp` registers both, and `GreetController.HasId` is only `True` when the longer one +`Routes.asp` registers both, and `GreetController.HasId` is only `True` when the longer one matched). **What `Router`/patterns do *not* give you**: a generic ASP.NET-MVC-style `{controller}/{action}/{id}` catch-all that dispatches to *any* controller/action pair. VBScript can't instantiate a script-defined `Class` from a string, so even a wildcard pattern still needs `Dispatcher` @@ -160,7 +162,7 @@ needs a static `Select Case controllerKey → New Controller` internally — unavoidable regardless of which file holds it, but it's confined to `Dispatcher` alone now (this limitation does NOT apply to picking the *view*, which is dynamic — see `DynamicIncludes` below). Adding a route means: new controller in `Core/Controllers/`, new view in `Core/Views/` named to match -the controller key, one `AddRoute` call in `Default.asp`, one `Case` branch in `Dispatcher.Dispatch`. +the controller key, one `AddRoute` call in `Core/Routes.asp`, one `Case` branch in `Dispatcher.Dispatch`. **`App.Route` depends on `HTTP_X_ORIGINAL_URL`, not `PATH_INFO`.** Because `Public/web.config` internally rewrites every request to `Default.asp`, `PATH_INFO` inside the page is always empty — diff --git a/Core/Bootstrap.asp b/Core/Bootstrap.asp index b7222e9..0689eda 100644 --- a/Core/Bootstrap.asp +++ b/Core/Bootstrap.asp @@ -26,11 +26,9 @@ Set oClockService = New ClockService Set oRequest = New HttpRequest Set oRouter = New Router Set oDispatcher = New Dispatcher - -oRouter.AddRoute "/", "Home" -oRouter.AddRoute "/greet/{name}", "Greet" -oRouter.AddRoute "/greet/{name}/{id}", "Greet" - +%> + +<% ' Left switched on deliberately - Default.asp's Match/Dispatch call runs ' under this same On Error Resume Next before checking Err.Number itself. On Error Resume Next diff --git a/Core/Routes.asp b/Core/Routes.asp new file mode 100644 index 0000000..89b84b4 --- /dev/null +++ b/Core/Routes.asp @@ -0,0 +1,5 @@ +<% +oRouter.AddRoute "/", "Home" +oRouter.AddRoute "/greet/{name}", "Greet" +oRouter.AddRoute "/greet/{name}/{id}", "Greet" +%>