9 "golang.org/x/net/websocket"
13 EventSource <-chan event
18 func (rtr *router) setup() {
19 rtr.mux = http.NewServeMux()
20 rtr.mux.Handle("/websocket", makeServer(handlerV0))
21 rtr.mux.Handle("/arvados/v1/events.ws", makeServer(handlerV1))
24 func makeServer(handler func(io.ReadWriter)) websocket.Server {
25 return websocket.Server{
26 Handshake: func(c *websocket.Config, r *http.Request) error {
29 Handler: websocket.Handler(func(ws *websocket.Conn) {
30 log.Printf("socket request: %+v", ws.Request())
33 log.Printf("socket disconnect: %+v", ws.Request().RemoteAddr)
38 func (rtr *router) ServeHTTP(resp http.ResponseWriter, req *http.Request) {
39 rtr.setupOnce.Do(rtr.setup)
40 rtr.mux.ServeHTTP(resp, req)