BREAKING CHANGE: Remove pointer from ContextNoBody and ContextWithBody, use interface directly in handlers #286
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.
We're moving Fuego Context from "generic type constrained by an interface" to "interface". We're doing this for two reasons.
First, to unify Fuego framework around one unique interface that every framework will implement, with
netHttpContext
,ginContext
,echoContext
. It also allows, like Echo, to provide custom Contexts for testing, and is very flexible.Second, because the hard thing with Generic Context type constrained by an interface is initialization. We have this ugly initialization function in
serve.go
calledinitContext
.With this PR, this unique interface is
ContextWithBody[B]
,ContextNoBody
being just an alias toContextWithBody[any]
. I wish there was anil
type, because I want to describe emptiness (nil), not "everything" (any), but Go does not allow that (that I know). When Go1.24 will go out, we will haveContext[B, P]
as main interface, and we'll keepContextWithBody[B]
as an alias toContext[B, any]
.Release notes draft
We're changing Fuego's signature from "generic type constrained by interface" to an interface
Simply replace
*fuego.ContextNoBody
byfuego.ContextNoBody
and*fuego.ContextWithBody
byfuego.ContextWithBody
Automatically make all required changes:
For macOS (BSD sed):
For Linux (GNU sed):