Skip to content
This repository has been archived by the owner on Mar 21, 2019. It is now read-only.

tango-contrib/websocket

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

2 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

websocket middleware for Tango

** IN DEVELOPMENT, API WILL CHANGED FREQUENTLY **

type Action struct {
    websocket.Message
}

func (w *Action) Get() {
    w.OnConnected(func(ws *websocket.Conn, sender chan []byte) {
        fmt.Println("on connected")
    }).OnReceived(func(ws *websocket.Conn, data []byte) {
        fmt.Println("on received", string(data))
    }).OnClosed(func(ws *websocket.Conn) {
        fmt.Println("ws closed")
    }).ListenAndServe()
}

func main() {
    tg := tango.Classic()
    tg.Use(websocket.New())
    tg.Get("/", new(Action))
    tg.Run()
}