Comments (12)
I am OK with the change. Btw we should return Req() and Resp() as interface.
from fiber.
@efectn we could also use this for the ctx interface
from fiber.
Sorry to bring this up again, but I figured I'd try to close the loop on this because the previous discussion kind of fizzled out when the Koa idea was brought up.
No worries if we want to keep the API as-is, it will be good to be able to point back to this proposal in the future either way.
Gist with sample implementation
https://gist.github.com/nickajacks1/2fd8bc71ba3a5a9839ebaf4313082efe
from fiber.
Ping @gofiber/maintainers
from fiber.
i like your proposal and gist, we can do it that way for all i care
this way the old api's still work and it's better separated
from fiber.
@efectn @gaby @sixcolors any ideas for this? otherwise someone can start with this or ?
from fiber.
https://github.com/rjeczalik/interfaces#cmdinterfacer-
from fiber.
@efectn we could also use this for the ctx interface
Sounds good idea
from fiber.
Sounds good, to keep it short and neady I vote for .Req / .Res interface. It's still good to allow users to access the underlying fasthttp pointers. Maybe ctx.Fasthttp() is an option, but should all methods be exposed in this one? If so, some functions might break internals, can place it "use at own risk" kinds thing ๐ or we limit it to fasthttp's request / response pointers only.
Feel free to comment
from fiber.
I also vote for .Req / .Res interface. Your example looks good.
I like ctx.Fasthttp().Res()
more than ctx.Res().Fasthttp()
but it doesn't really matter. I could easily be convinced it should be the other way.
from fiber.
Thanks for the feedback. I'll get started.
I think that fasthttp gives you enough ways to shoot yourself in the foot that accessing it should be a "use at your own risk" type of thing, but leaving it available for use is probably a good idea just in case someone really needs it due to gaps in the fiber public API.
Should the existing ctx.Request()
and ctx.Response()
be left alone, marked deprecated, or removed? Today, they return the fasthttp objects, but they're also available using c.Context().Request
. It would be confusing to have more than one method that returns a "request" or "response" object, but removing it entirely would be one more breaking change. Maybe that's fine since it's a new major version and it can be fixed with a find+replace.
from fiber.
I lean toward removing redundant or similarly named functions that would make the framework confusing. Accessing the underlying fasthttp pointer should be very explicit so I favor the ctx.Fasthttp() approach.
This would be breaking and I think v3 is a good opportunity to clean up and improve our approach. But, i think we really need to start a v2 => v3 migration guide. I recently did a migration of play billing lib for an Android app and think Google did a good job of their guide https://developer.android.com/google/play/billing/migrate-gpblv6
What does everyone else think?
from fiber.
Related Issues (20)
- Explore Performance Optimization: Using a Pool for Memory Allocation in Client Package HOT 1
- Update Documentation and README.md for Client Package Refactor HOT 1
- ๐ [Bug]: local variable based on ctx.Method() is changed in goroutine HOT 5
- ๐ค [Question]: How can i keep a connection alive untill timeout or i response some message? HOT 1
- ๐ค [Question]: Custom Listen Function HOT 3
- CSRF Trusted Origins HOT 2
- ๐งน [Maintenance]: Update RFC Draft for Idempotency Middleware HOT 1
- Have I found a bug in BodyParser, or am I an idiot? HOT 4
- ๐ [Bug]: CORS middleware misclassifies all OPTIONS requests as preflight requests HOT 1
- ๐ค [Question]: Rate limit per path HOT 5
- ๐ค [Question]: How do I get default logger to log error HOT 2
- ๐ค [Question]: how to Get status code in middleware HOT 5
- ๐ [Proposal]: Add Helpers for Internal IP Ranges HOT 4
- ๐ [Bug]: version v2.52.2 up to v2.52.3 , cors error HOT 22
- ๐ [Bug]: serving a compress enabled public folder without +w permissions results in a 404 HOT 3
- ๐ *** CLOSE - I see Context( ) returns this type .... *** - r4[Proposal]: Add RequestCtx in ctx that returns *fasthttp from DefaultCtx HOT 5
- ๐ [Bug]: CORS issue HOT 2
- ๐ [Proposal]: Allow disabling cache for ctx.SendFile() HOT 2
- ๐ [Bug]: Data race on shutdown HOT 8
- ๐ค [Question]: Calling other endpoints without network HOT 7
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. ๐๐๐
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google โค๏ธ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from fiber.