Problem
A prebuilt Response is documented and typed as an ActionHandler, but bun-router records it in staticResponses: Map<string, Response>. The HTTP method is discarded.
On Bun 1.4.2, the Bun.serve({ static }) table serves a path for every HTTP method. This means:
router.post('/ready', new Response('posted'))also answers GET /ready, and registering two static responses for the same path lets the later method overwrite the earlier one. The registration also overwrites duplicate method/path entries even though the fetch router uses first registration wins.
The static table is not rebuilt by router.reload(), so prebuilt responses can disappear after reload.
Bun 1.4.2 evidence
A direct Bun probe returned the static response for both GET and POST. A method-scoped native route preserves the intended contract:
routes: {
'/ready': { POST: new Response('posted') },
}An absent method falls through to fetch, which lets bun-router retain its existing 404, 405, middleware, and fallback semantics. GET continues to answer HEAD automatically.
Proposed fix
- Retain prebuilt responses by path and HTTP method.
- Merge them into Bun's method-scoped
routestable onserve()andreload(). - Merge compatible dynamic native routes into the same table when
nativeRoutes: true. - Preserve first registration wins for each method/path pair.
- Add Bun 1.4.2 HTTP coverage for method isolation, multiple methods on one path, duplicate registration, fetch fallback, and reload.
- Keep prebuilt responses on Bun's zero-allocation path without invoking middleware or request context.