Skip to content

darmawan01/ws-wrapper

Repository files navigation

Websocket Wrapper

Write your Websocket message routing like http route handler.

Use the JSON RPC Specification

Usage

Get dependencies

go get github.com/darmawan01/ws-wrapper

Register websocket wrapper handler

engine := gin.Default()

router := engine.Group("/api")

/* Register websocket route */
router.GET("/ws", func(ctx *gin.Context) {
    /* Websocket wrapper handler */
    ws.WebsocketHandler(ctx.Writer, ctx.Request)
})

Registering your method handler

ws.RegisterChannelHandler("public/health", h.healthCheck)