Websockets
The package was converted to work with fasthttp, is fork of https://github.com/gorilla/websocket.
WebSocket is a protocol providing full-duplex communication channels over a single TCP connection. The WebSocket protocol was standardized by the IETF as RFC 6455 in 2011, and the WebSocket API in Web IDL is being standardized by the W3C.
WebSocket is designed to be implemented in web browsers and web servers, but it can be used by any client or server application. The WebSocket Protocol is an independent TCP-based protocol. Its only relationship to HTTP is that its handshake is interpreted by HTTP servers as an Upgrade request. The WebSocket protocol makes more interaction between a browser and a website possible, facilitating the real-time data transfer from and to the server.
Read more about Websockets
How to use
import (
"github.com/fasthttp-contrib/websocket"
"github.com/vayala/fasthttp"
)
func chat(c *websocket.Conn) {
}
var upgrader = websocket.New(chat)
func myChatHandler(ctx *fasthttp.RequestCtx) {
err := upgrader.Upgrade(ctx)
}
func main() {
fasthttp.ListenAndServe(":8080", myChatHandler)
}
If you want to see more examples just go here and make the conversions as you see in 'How to use' before.