Skip to content

add Router to chadscript/http, fix routing bugs, restructure docs#86

Merged
cs01 merged 5 commits intomainfrom
worktree-docs-restructure
Mar 4, 2026
Merged

add Router to chadscript/http, fix routing bugs, restructure docs#86
cs01 merged 5 commits intomainfrom
worktree-docs-restructure

Conversation

@cs01
Copy link
Owner

@cs01 cs01 commented Mar 4, 2026

Summary

  • Merge Router into chadscript/httplib/router.ts is deleted; Router, Context, and RouterRequest now live in lib/http.ts alongside httpServe. Single import, no separate module.
  • Fix HTTP router bugs — regex used (?:...) (POSIX PCRE syntax), which is invalid in POSIX ERE (used by the regex bridge). Changed to (...) with group offset adjusted from 1 to 2. Router now correctly matches routes and dispatches handlers.
  • Fix builtin interface type registration — handler parameters typed as HttpRequest/HttpResponse/WsEvent/MultipartPart and variables returned from Router.handle() now get correct object metadata so field access (.status, .body, .path, etc.) generates the right GEP indices. Previously these fell through to the %__FetchResponse path and either crashed or returned garbage.
  • Docs restructure — reorganized into Getting Started / Language / Standard Library sections with neutral tone; added IDE Setup and FFI pages.

Test plan

  • npm test passes (401/401)
  • Router import from chadscript/http works — import { httpServe, Router, Context } from "chadscript/http"
  • Route matching: app.get("/users/:id", ...) correctly extracts params
  • Default 404 (no app.notFound()) returns { status: 404, body: "Not Found" }
  • const r = app.handle(req); r.status; r.body compiles and returns correct values
  • HTTP server integration test (tests/network.test.ts) passes

🤖 Generated with Claude Code

cs01 added 5 commits March 4, 2026 00:06
… for method returns

- lib/http.ts: replace non-capturing group (?:...) with capturing group (...) for posix ere compat; adjust group offset from 1 to 2
- class.ts, function-generator.ts: register builtin d.ts interface types (httprequest, httpresponse, wsevent, multipartpart) as object metadata for handler params
- type-inference.ts: return builtin d.ts interface type names from getMethodCallInterfaceReturn when getInterface() returns null
- variable-allocator.ts: handle builtin d.ts interfaces in allocateMethodInterfaceReturn so variables from router.handle() get correct field metadata
- tests/network.test.ts: use polling waitForServer instead of fixed 500ms sleep
- fix test fixtures to match expected output
@cs01 cs01 changed the title docs update add Router to chadscript/http, fix routing bugs, restructure docs Mar 4, 2026
@cs01 cs01 changed the title add Router to chadscript/http, fix routing bugs, restructure docs add Router to chadscript/http, fix routing bugs, restructure docs Mar 4, 2026
@cs01 cs01 merged commit b71919d into main Mar 4, 2026
12 checks passed
@cs01 cs01 deleted the worktree-docs-restructure branch March 4, 2026 16:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant