Repository navigation
feat(router): typed c.res response view on both surfaces (issue #57) - #79
Merged
Merged
Conversation
Contributor
|
I'll fix CI failures and address comments from users with write access. I'll skip comments containing "(aside)".
|
- ResponseSink gains statusOf()/headerOf()/headersMap() read-back
accessors, implemented on NodeResponseSink (_status + _set) and
FetchResponseSink (status + hdrKeys/hdrVals).
- Ctx.res is now a CtxRes view (status, header(name), headers) backed by
the sink — same shape under app.handler and app.fetch, so hono/logger's
outbound --> line prints the real status after await next(). statusCode
is kept as a Node-shaped alias; nodeRes() exposes the raw
ServerResponse escape hatch (c._nodeRes unchanged for @chttp/static
and @chttp/stream).
- use() middleware now also wraps the notFound chain (Hono semantics:
app.use('*', mw) must observe 404s).
- c.req.url reports the absolute Request URL on the app.fetch surface —
hono/logger derives the path via url.slice(url.indexOf('/', 8)).
- Unskips the two outbound --> logger tests; adds c.res.status (404) and
c.res.header('content-type') (json) coverage on both surfaces.
- Updates otlp-traces/prometheus-metrics examples and docs/middleware.md
to the new accessor.
devin-ai-integration
Bot
force-pushed
the
devin/1792346815-ctx-res-status
branch
from
October 18, 2026 18:19
92bf70e to
d30e750
Compare
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
Implements #57 —
c.resis now a typed, read-only response view that works identically on both surfaces, sohono/logger's outbound-->line (and thecompress/etag/prettyJSONHono middlewares that readc.res.statusafterawait next()) get a real status code.CtxResview (CtxResCore+CtxResinterface/const, same pattern asCtx/ReqView):ResponseSinkread-back accessors —statusOf(),headerOf(),headersMap()added beside the existing write-side members;NodeResponseSinkserves them from_status+_set,FetchResponseSinkfromstatus+hdrKeys/hdrVals(last-wins dedup). Noinstanceof/as— same discrimination style assink.nodeRes().Two adjacent gaps the unskipped tests surfaced, fixed here:
use()middleware never ran on the default 404 chain —_nfchainwas only recomposed insidenotFound().use()now keeps_nfchain = compose(copyMw(this._mw), this._nf)in step (Hono semantics:app.use('*', mw)observes misses too). Per-route middleware snapshots in_mwsare untouched.c.req.urlon the fetch surface is now the absolute Request URL (http://host/path), matching Hono — hono/logger derives the path viaurl.slice(url.indexOf("/", 8)), which misread the previous path-only value ("g"for/missing). Node surface stays path+query-only (IncomingMessage.urlcarries no host);c.req.path/queries()unchanged.Downstream compat:
@chttp/staticand@chttp/streamalready readc._nodeRes(unchanged);otlp-traces/prometheus-metricsexamples keep working via thestatusCodealias;docs/middleware.mdraw-write snippets now go throughc.res.nodeRes().Tests
-->tests inexamples/integrations/hono-middleware/test/logger.test.ts(200 and 404 — assertions strip ANSI status colors).router.test.js(Node surface) andfetch-passthrough.test.js(fetch surface):c.res.statusafter a 404 andc.res.header('content-type')after ac.json()write, observed from middleware afterawait next().Gates
pnpm -r test: all green (83 router tests + workspace incl. the 3 hono-middleware tests).bash scripts/scriptc-gate.sh: 100% static on all gates incl.bench/apps/chttp-fetch.ts.pnpm lint/pnpm fmt: clean.Link to Devin session: https://app.devin.ai/sessions/7b9534a797564587b9d517a904dfd268
Open in Devin Desktop: https://app.devin.ai/desktop/session/7b9534a797564587b9d517a904dfd268?variant=devin
Requested by: @espetro