Experiment with Authentication and Websockets
Some checks failed
build-docker-imge / Build the docker container (push) Failing after 2m24s
Some checks failed
build-docker-imge / Build the docker container (push) Failing after 2m24s
This commit is contained in:
20
middleware/ws.go
Normal file
20
middleware/ws.go
Normal file
@ -0,0 +1,20 @@
|
||||
package middleware
|
||||
|
||||
import (
|
||||
"github.com/gofiber/contrib/websocket"
|
||||
"github.com/gofiber/fiber/v2"
|
||||
)
|
||||
|
||||
type WsMiddleware struct {
|
||||
}
|
||||
|
||||
func NewWsMiddleware() WsMiddleware {
|
||||
return WsMiddleware{}
|
||||
}
|
||||
|
||||
func (wm WsMiddleware) IsWebscoketUpgrade(ctx *fiber.Ctx) error {
|
||||
if websocket.IsWebSocketUpgrade(ctx) {
|
||||
return ctx.Next()
|
||||
}
|
||||
return ctx.SendStatus(fiber.StatusUpgradeRequired)
|
||||
}
|
||||
Reference in New Issue
Block a user