Skip to content

Instantly share code, notes, and snippets.

@ilovelili
Created April 25, 2024 08:51
Show Gist options
  • Save ilovelili/905447f2192b855677ab1e2fdcc21738 to your computer and use it in GitHub Desktop.
Save ilovelili/905447f2192b855677ab1e2fdcc21738 to your computer and use it in GitHub Desktop.
// Handle $connect event
func connectHandler(c echo.Context) error {
// Extract connection ID from headers
connectionID := c.Request().Header.Get("Sec-WebSocket-Protocol")
// Perform actions when a client connects
fmt.Printf("Client connected: %s\n", connectionID) // ==========> we didn't get the connectionID, it's empty
// Respond with a 200 status code
return c.String(http.StatusOK, "Connected")
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment