Open gaby opened 1 year ago
Thanks for the feature request! Adding support for fasthttp is not on my immediate TODO list, but I like the idea.
If the goal is increased performance, is ie. echo (which supports net/http
interfaces) an alternative?
@xyproto I'm one of the maintainers for @GoFiber which is based on fasthttp. Looking at the examples I could try using your library with the net/http to fasthttp adaptor. If I get it to work I will share an example here.
Using https://github.com/valyala/fasthttp/fasthttpadaptor should work.
I am using it here: https://github.com/xyproto/algernon/blob/main/engine/serve.go
I'll have to try using it together with permissions2 to see if any changes to permissions2 is needed.
@xyproto The problem with adaptor is that it adds overhead. So if you are checking for auth
in all your handlers, they will all get slower.
Another thing, your examples folder is part of permissions2
. This makes it so that anyone using module has to install a lot of dependencies.
https://github.com/xyproto/permissions2/blob/main/v2/go.mod#L6
So even if i have a fasthttp server, my go.mod will end with gin, chi, martini, negroni, etc which are not needed for permissions2
I see, I thought the overhead of fasthttpadaptor was minimal, but I have not benchmarked it yet.
What would be the best way to support fasthttp? To add a middleware function, like lu does? https://github.com/vincentLiuxiang/lu
Thanks for pointing out the issue with the examples
folder, I am renaming it to cmd
.
I gave you full access to this repository, btw, in case you have a good plan for adding support for fasthttp and want to add it. I would have to look more into fasthttp first.
@xyproto Yes, the best way is to have a native fasthttp middleware.
Adaptor while great it has convert/adapt each net/http to a fasthttp ctx.
An excellent examples for using adaptor: Prometheus Endpoint
I gave you full access to this repository, btw, in case you have a good plan for adding support for fasthttp and want to add it. I would have to look more into fasthttp first.
Will do, thanks 💪
btw, if fasthttp needs to be imported by permissions2 in order to support fasthttp, that would require all users of permission2 to also get fasthttp as a dependency, right? Is there a way to support fasthttp without having to import it in permissions2?
@xyproto They have instructions here https://github.com/valyala/fasthttp?tab=readme-ov-file#switching-from-nethttp-to-fasthttp
Would have to check what sections of net/http permissions2
is using.
Yes, it would require importing it. I have to think if there's a way around that by creating an interface.
In worst case, perhaps a separate permissions package for supporting fasthttp would be needed.
I will do a PR tonight to update the CI process first. Will look imto fasthttp after that. 💪
Hello, are there any plans to add support for fasthttp? https://github.com/valyala/fasthttp https://github.com/valyala/fasthttp#switching-from-nethttp-to-fasthttp
Thanks!