- FileText: now respects the provided status code instead of defaulting to 200 OK
- Request body limits: prepareRequestBody() is now only called when MaxRequestBodySize > 0
- ShouldBindJSON, ShouldBindWANF, ShouldBindGOB, ShouldBindForm, GetReqBody, PostForm
all now use the original c.Request.Body path when no limit is configured
- maxBytesReader: fixed exact-limit boundary case where body size == limit was
incorrectly rejected
- Added regression tests for FileText status codes and body limit behavior
All existing tests pass, and new tests verify the corrected behavior.
- Remove fallback to HTML() on template rendering failure
- Return 500 error without writing any content on error
- Only fallback to HTML() when renderer is nil or unsupported type
- Prevents multiple response writes
Reduce code duplication by calling c.HTML() for fallback cases:
- When template rendering fails
- When HTMLRender is not configured
- When HTMLRender is not a *template.Template
This ensures consistent behavior between HTMLBuf and HTML methods.
Add buffered rendering methods that encode to a buffer first, then
write the response. This allows returning a proper 500 status code
if encoding fails, unlike the streaming variants which must write
the status code before encoding (an inherent HTTP constraint).
New methods:
- JSONBuf(code int, obj any)
- GOBBuf(code int, obj any)
- WANFBuf(code int, obj any)
- HTMLBuf(code int, name string, obj any)
Trade-off: one extra memory allocation per call in exchange for
correct error status codes on encoding failure.
Address PR review feedback:
- Capture w := c.Writer before goroutine start, use w (not c.Writer)
inside the goroutine to avoid holding *Context reference
- Move channel send into select alongside context cancellation in all
examples and tests, preventing goroutine leak when client disconnects
while blocked on unbuffered send
BREAKING CHANGE: EventStreamChan signature changed from
(chan<- Event, <-chan error)
to
(eventChan <-chan Event)
The caller now creates and passes the channel instead of receiving it.
The errChan return value is removed.
The old non-blocking design allowed the handler to return before the SSE
stream ended, causing ServeHTTP to return the Context to the pool while
the internal goroutine was still writing to the pooled writer — a data
race across requests. The new blocking design keeps the handler inside
EventStreamChan until the event channel is closed or the client
disconnects, ensuring the Context remains bound throughout the stream.
- Caller creates channel, producer goroutine sends events
- EventStreamChan blocks handler until stream ends
- Internal goroutine captures stable references (Flusher, context.Context)
instead of holding *Context pointer
- Nil guard on Flusher type assertion
- Add sse_test.go covering blocking, disconnect, and event format
- Update docs/sse.md for new API
Clarify that outgoing proxy queries are normalized before forwarding, which may re-encode or drop non-standard fragments to keep parsing behavior consistent across proxy chains.
Preserve final headers when forwarding 1xx responses, reject invalid 101 upgrade negotiations, and make the default Via token RFC-safe. Tighten the reverse proxy tests around goroutine synchronization and document the Via fallback behavior more clearly.
Document BufferPool usage and explain why trailer fallback and disconnect compatibility logic intentionally mirror the standard library reverse proxy. Add a regression test covering unannounced trailer forwarding so that proxy trailer behavior stays aligned with Go's semantics.
Provide an RFC-aware reverse proxy handler so Touka services can forward normal, streaming, and upgraded HTTP traffic without leaving the framework. Document the new API and proxy-chain behavior so deployments behind other gateways preserve forwarding metadata correctly.
- Implemented \`applyDefaultServerConfig\` in \`Engine\` to apply \`serverProtocols\` to \`http.Server\`.
- Uncommented all calls to \`applyDefaultServerConfig\` in \`serve.go\`.
- Refactored \`SetProtocols\` and added internal \`setProtocols\` to ensure user-defined protocols are not overwritten by framework defaults in \`RunTLS\`.
- Added exhaustive tests in \`protocols_test.go\` to verify protocol inheritance and persistence.