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

Latest commit

 

History

History
27 lines (22 loc) · 589 Bytes

README.md

File metadata and controls

27 lines (22 loc) · 589 Bytes

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()
}