release: promote develop → main (staging) #5
No files matched your search
@@ -34,6 +34,11 @@ green-tea uses calendar versioning: `YY.MM.PATCH`.
|
||||
fields such as `req.socket` / `req.rawHeaders` are no longer available on
|
||||
`ctx.req`; use `ctx.protocol` / `ctx.ip` / `ctx.query` / `ctx.headers`
|
||||
instead — all still provided.
|
||||
- **Breaking (pre-1.0): transport is now enforced by declaration.** A buffered route
|
||||
(`@Get`/`@Post`/`@Put`/`@Patch`/`@Delete`) whose handler returns an `AsyncIterable`, or a streaming
|
||||
route (`@Sse`/`@Ws`) whose handler returns a plain value, now fails with a 500 `TransportMismatchError`
|
||||
instead of silently switching behavior. `@Stream` still negotiates both. Declare `@Sse`/`@Stream`/`@Ws`
|
||||
to stream — a return value no longer changes a route's wire contract.
|
||||
|
||||
## [26.7.0-beta.0] - 2026-07-07
|
||||
|
||||
|
||||
@@ -62,10 +62,13 @@ class UserController {
|
||||
|
||||
Same filesystem requirement as file mode: Node/Deno/Bun only.
|
||||
|
||||
:::caution[Return a string or data, never an `AsyncIterable`]
|
||||
An `@Html` handler must return a string (bare mode) or a data object (template mode). Don't
|
||||
return an `AsyncIterable` — the pipeline detects async-iterable returns and streams them raw,
|
||||
bypassing the HTML transformer entirely, so your markup never gets wrapped or rendered.
|
||||
:::caution[Return the right shape for each mode — never an `AsyncIterable`]
|
||||
`@Html` is a buffered route, so its return contract follows the mode: bare `@Html` returns a
|
||||
`string`; `@Html('file.html', { template: true })` returns the data object rendered into the
|
||||
template; `@Html('file.html')` (no template) ignores the return entirely — annotate it `: void`
|
||||
by convention, e.g. `page(@needs('x')): void {}`. Returning an `AsyncIterable` from any `@Html`
|
||||
handler is the same buffered-route mismatch as any other `@Get`/`@Post`/`@Put`/`@Patch`/`@Delete`
|
||||
handler: a 500 `TransportMismatchError`, not a silent raw stream.
|
||||
:::
|
||||
|
||||
## The `views` base directory
|
||||
|
||||
@@ -104,11 +104,14 @@ Same `@Route`, same handler shape, same `AsyncIterable` — real-time is not a s
|
||||
|
||||
`rooms` is the built-in shared `Rooms` primitive (one instance app-wide). A typical chat handler pumps the `@inbound()` channel into `rooms.room(name)` and returns that same room as its outbound channel, so every joined socket multicasts to the others. A handshake `@Step` can read `?token=` and throw `Unauthorized` — which closes the socket with code **4401** (`4000 + status`). See [security](/guides/security/) for handshake authentication.
|
||||
|
||||
## The one rule to remember
|
||||
## Transport is declared, not inferred
|
||||
|
||||
```
|
||||
return a VALUE → buffered response (transformer → JSON)
|
||||
return an AsyncIterable → stream (SSE / WS)
|
||||
```
|
||||
A route streams **because** it's declared `@Sse`, `@Stream`, or `@Ws` — never because a handler happened to return an `AsyncIterable`. In most frameworks the return type decides the wire format; in green-tea the decorator decides, and the return value is enforced against it:
|
||||
|
||||
Return a value and you get a buffered JSON response; return an `AsyncIterable` and you get a stream. That's the whole contract.
|
||||
| Declare | Handler must return | Otherwise |
|
||||
|---|---|---|
|
||||
| `@Get` / `@Post` / `@Put` / `@Patch` / `@Delete` (buffered) | a value | returning an `AsyncIterable` fails with a 500 `TransportMismatchError` |
|
||||
| `@Sse` / `@Ws` (streaming) | an `AsyncIterable` | returning a plain value fails with a 500 `TransportMismatchError` |
|
||||
| `@Stream` (negotiate) | either | the client picks via `Accept` / `Upgrade` — no mismatch |
|
||||
|
||||
This is the anti-Express guarantee: your wire contract is what you **declared**, never a surprise sprung by a return value. A buffered route can't accidentally start streaming because someone returned a generator; a streaming route can't silently downgrade to a buffered response because someone forgot a `yield`. Declare `@Sse` / `@Stream` / `@Ws` to stream — the return value never changes a route's transport.
|
||||
Reference in new issue
Block a user