Giter VIP home page Giter VIP logo

Comments (12)

efectn avatar efectn commented on May 18, 2024 1

I am OK with the change. Btw we should return Req() and Resp() as interface.

from fiber.

ReneWerner87 avatar ReneWerner87 commented on May 18, 2024 1

@efectn we could also use this for the ctx interface

from fiber.

nickajacks1 avatar nickajacks1 commented on May 18, 2024

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.

gaby avatar gaby commented on May 18, 2024

Ping @gofiber/maintainers

from fiber.

ReneWerner87 avatar ReneWerner87 commented on May 18, 2024

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.

ReneWerner87 avatar ReneWerner87 commented on May 18, 2024

@efectn @gaby @sixcolors any ideas for this? otherwise someone can start with this or ?

from fiber.

ReneWerner87 avatar ReneWerner87 commented on May 18, 2024

https://github.com/rjeczalik/interfaces#cmdinterfacer-

maybe via go:generate
image

from fiber.

efectn avatar efectn commented on May 18, 2024

@efectn we could also use this for the ctx interface

Sounds good idea

from fiber.

Fenny avatar Fenny commented on May 18, 2024

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.

sixcolors avatar sixcolors commented on May 18, 2024

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.

nickajacks1 avatar nickajacks1 commented on May 18, 2024

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.

sixcolors avatar sixcolors commented on May 18, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.