Golang Turbo Stream Package

For use with hotwire turbo, this package allows you to quickly get up and running with responding to websockets with turbo-streams

Basic Examples

Create a message hub

	hub = turbostream.NewHub()
	go hub.Run() 

Add to your websocket handler (gorilla in this case)

    r.HandleFunc("/ws", websocketHandler)
    func websocketHandler(w http.ResponseWriter, r *http.Request) {
    	turbostream.HandleWs(hub, session_id, w, r)

Broadcast a Message to all clients


Send a message to a specific client

    err:= hub.Send(session_id,turbostream.Message("append","example_div_id","Hello!"))
		fmt.Fprintf(w, err.Error())


View Github