httprouter
httprouter copied to clipboard
Add support for fasthttp
fasthttp is a fast http server with zero memory allocations like httprouter. It would be great if support for fasthttp will be added to httprouter. This will give us fast http server+router with zero memory allocations.
I am wondering, since httprouter
would probably want to keep their API stable, what would this look like?
- One could probably convert
fasthtp.RequestCtx
to ahttp.Request
object - (nullifying the performance gain?) - One could probably convert
fasthttp.RequestCtx
to implementhttp.Responsewriter
- but again, as it's not anhttp.ResponseWriter
already, I would feel like this doesn't leave us with much performance gain either. - One could combine the two projects, resulting in a different API.
With "stable API", I mean: I expect @julienschmidt to want to keep the syntax:
func Hello(w http.ResponseWriter, r *http.Request, ps httprouter.Params) {}
Do you have any thoughts / ideas about this yourself, @valyala ?
The project is very interesting. I talked about something like that with @manucorporat a while ago. However support can not be simply added to httprouter as its API is designed for net/http. I think the best option would be to maintain a fork for fasthttp instead. I'd be happy to do that as soon as I fixed some stuff here in the main repo.
I'd be happy to do that as soon as I fixed some stuff here in the main repo.
This would be great!
What are we looking at for a timeline for this? Would you like any help with the fork? Thanks!
Hi all.
I had forked [httprouter] and make it work for [fasthttp]. But there are too many conflicts with go's net/http package. It is hard to merge into the main repo, so I rename it as an individual package fasthttprouter.
All docs and tests are available and the package has been used in our online productions. Just enjoy it.
Thanks @buaazp for your work.
@buaazp looks great; planning on digging into your library to build a framework with middleware and such Sunday or Monday.
Can I ask how you are going to maintain fasthttprouter as httprouter evolves? Why don't you have issues enabled for it (are you not looking to maintain this long-term?)?
Hi @Annonomus-Penguin , forked repos disable issues by default, now I have opened it. I will rebase the httprouter's commits into fasthttprouter over a period of time. Before I can make a PR for httprouter. I wish httprouter can support fasthttp finally. But the interfaces are different and it's a little hard to do that. And, of cause, I will maintain fasthttprouter as a long-term project because it's used in my productions. If there are bugs, file it to me.