add Router to chadscript/http, fix routing bugs, restructure docs#86
Merged
add Router to chadscript/http, fix routing bugs, restructure docs#86
Conversation
…neutral tone, ffi page, ide setup page
… 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
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Routerintochadscript/http—lib/router.tsis deleted;Router,Context, andRouterRequestnow live inlib/http.tsalongsidehttpServe. Single import, no separate module.(?:...)(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.HttpRequest/HttpResponse/WsEvent/MultipartPartand variables returned fromRouter.handle()now get correct object metadata so field access (.status,.body,.path, etc.) generates the right GEP indices. Previously these fell through to the%__FetchResponsepath and either crashed or returned garbage.Test plan
npm testpasses (401/401)Routerimport fromchadscript/httpworks —import { httpServe, Router, Context } from "chadscript/http"app.get("/users/:id", ...)correctly extracts paramsapp.notFound()) returns{ status: 404, body: "Not Found" }const r = app.handle(req); r.status; r.bodycompiles and returns correct valuestests/network.test.ts) passes🤖 Generated with Claude Code