chore: encapsulate Ctx.Patch behind a method#98
Merged
Conversation
Ctx.Patch was the only exported field across every otherwise-opaque runtime type (Ctx, CtxR, Session, File, Ticker, App, Group) — all of which expose state through methods. A lone mutable public field let callers reassign or nil the push handle (ctx.Patch = nil) and broke the all-methods consistency of the type. Unexport the field to `patch` and add `func (ctx *Ctx) Patch() *Patch`, matching the shape of Request(), Session(), Writer(). The handle is still allocated eagerly in newCtx, so the accessor is a plain field load. Call sites move from `ctx.Patch.Signal(...)` to `ctx.Patch().Signal(...)`. Breaking change, but pre-1.0 and a strict hardening — the field can no longer be swapped out from under the runtime.
This was referenced Jun 9, 2026
joaomdsg
added a commit
that referenced
this pull request
Jun 10, 2026
…e scope (#109) - Document WithMaxUploadSize (32 MiB multipart) + WithRequestTooLarge hook across file-uploads, production, troubleshooting guides - Fix stale ctx.Patch field form -> ctx.Patch() method (post #98) - Note WithRequestTooLarge covers action POSTs only; SSE-close bodies always get the bare 413
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.
Next API-surface cleanup (follows #97).
Finding
Ctx.Patchwas the only exported field across every otherwise-opaque runtime type (Ctx,CtxR,Session,File,Ticker,App,Group) — all of which expose state via methods. A lone mutable public field let callers doctx.Patch = nil/ swap the handle, and broke the all-methods consistency ofCtx.Change
Patch→patch.func (ctx *Ctx) Patch() *Patch, mirroringRequest()/Session()/Writer(). Still a plain field load (handle allocated eagerly innewCtx).ctx.Patch.Signal(...)→ctx.Patch().Signal(...).Breaking change, but pre-1.0 (v0.5.0) and a strict hardening — the runtime's push handle can no longer be reassigned out from under it.
Verification
go build,go vet,gofmt -l(clean),go test -race ./...— all green (incl. maplibre plugin tests that used the handle).