Closed xieyuschen closed 1 year ago
If you don't understand things like this you really shouldn't be using fasthttp! There will be no benefit to you, only downsides. You're going to run into all kinds of fasthttp related bugs if you don't completely understand the code. fashttp only has benefits if you really understand how to use it, otherwise it will just be buggy and slower than net/http for you.
Please use net/http
!
There is https://pkg.go.dev/github.com/valyala/fasthttp/fasthttpadaptor if you really need it, but if you're going to use that you might as well completely use net/http as all speed benefits are gone.
The
fasthttp.Serve
receives anet.Listener
and handlers, and then if there are bytes in the listener, fasthttp will read and construct a request, then trigger the handler and finally write the response back to the socket.My question is, why don't we implement the
http.Handler
? This question was raised because I want to trigger fasthttp handlers by anhttp.Request
object but I haven't found this method.The readme gives me a hint. Based on this explanation, I acknowledge it's reasonable that if we support the
http.Handler
,fasthttp
itself will lose its strength because the small to medium requests cannot be reused anymore.As I am not familiar to fasthttp much, could I ask you guys this question? Why at the beginning haven't we decided to support it?
Regards