-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
websockets support #18
Comments
I have a rough version working now. The gorilla This works fine with my simple JavaScript websockets code. I still think this would be better if done in gorilla, so I will try adding that next. I made just have to add a new I don't yet know if the gorilla project will be open to adding support for |
@leavengood , there are plans to add websockets support to fasthttp, but currently I'm busy with other stuff. So it would be great if somebody implements websockets on top of fasthttp. |
I have implemented a first attempt at supporting fasthttp in the gorilla websocket package. It can be seen in my fork: A lot of the changes are just making various utility functions usable for both leavengood/websocket@a24f11b#diff-34c6b408d72845d076d47126c29948d1R222 I have copied the style of the normal handler := func(c *websocket.Conn) {
// Do something with the connection
}
upgrader := &websocket.FastHTTPUpgrader{
Handler: handler,
// Don't check the origin header
CheckOrigin: func(ctx *fasthttp.RequestCtx) bool { return true },
}
if err := fasthttp.ListenAndServe(":12345", upgrader.UpgradeHandler); err != nil {
log.Fatalf("Error in ListenAndServe: %s", err)
} Let me know what you think of this, and I can see about adding some tests and then making a PR to the main gorilla websocket repo. |
I made a PR and have made some adjustments to account for |
@leavengood , gorilla/websocket#98 looks cool! It would be great if it will be merged eventually into gorilla websockets. |
It may need some more tweaking but they seem to be open to the idea. Worse case I could maintain a fork with fasthttp support. Their project seems pretty stable with a few commits now and then, so it wouldn't be hard to keep a fork up-to-date. For the moment if other people need this they can use my fork, though at the moment the new code is in a fasthttp branch. |
Gorilla websockets does not currently want to merge in my changes, so I have closed the PR and merged that code into the master branch of my fork (https://github.com/leavengood/websocket). If anyone wishes to use websockets with fasthttp, they can import my fork. I'm going to close this issue as well. |
@leavengood , I mentioned your library in README.md. |
My coworkers and I are a big fan of
fasthttp
, it has proven very useful for a work project and we find it very ergonomic to use.I now have need for websockets with a
fasthttp.Server
. What is the plan for websockets support in fasthttp?There are two major Go packages for websockets:
The former is a bit easier to use and probably is considered the "standard" Go websockets package since it comes from the Go team. Nonetheless the gorilla websockets seems to support the standard better and it appears more flexible and not as tied to
net/http
as the golang/net version.I plan to fork gorilla/websocket and add a fasthttp version of the
Upgrade
method:https://godoc.org/github.com/gorilla/websocket#Upgrader.Upgrade
If anyone is working on this, or if there are other ideas on how to get websockets working with fasthttp, please reply.
The text was updated successfully, but these errors were encountered: