You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We propose implementing the fluent concept for the methods Status and Type in the Fiber framework using generics, as discussed in the following articles:
Using generics allows for method chaining by having methods return a generic interface type, similar to the self keyword in other languages. Since Go does not have a self keyword, generics provide a feasible alternative without significant language changes.
Proposal:
Modify the Context Interface:
Change methods like Status and Type to return a generic interface instead of a concrete type.
This enables fluent method chaining while maintaining type safety and flexibility.
Implement a Generic Ctx Interface on App:
To prevent class switching when registering a custom context that uses fluent methods, implement a generic interface for Ctx on the App.
Provide Multiple New Methods:
Offer additional constructor methods so developers who do not need a custom context can continue using fiber.New without any changes.
Provide alternative constructors for those who wish to customize the context.
Benefits:
Maintains ease of use for existing users.
Enhances flexibility for developers requiring custom contexts.
Utilizes Go's generics feature introduced in 1.18 for improved design patterns.
We propose implementing the fluent concept for the methods
Status
andType
in the Fiber framework using generics, as discussed in the following articles:Background:
Using generics allows for method chaining by having methods return a generic interface type, similar to the
self
keyword in other languages. Since Go does not have aself
keyword, generics provide a feasible alternative without significant language changes.Proposal:
Modify the
Context
Interface:Change methods like
Status
andType
to return a generic interface instead of a concrete type.This enables fluent method chaining while maintaining type safety and flexibility.
Implement a Generic
Ctx
Interface onApp
:Ctx
on theApp
.Provide Multiple
New
Methods:fiber.New
without any changes.Benefits:
References:
Requested by: @ReneWerner87
The text was updated successfully, but these errors were encountered: