func main() { gosockjs.Install("/echo", echo) dwe, err := gosockjs.Install("/disabled_websocket_echo", echo) if err != nil { log.Println(err) } dwe.WebsocketEnabled = false cne, err := gosockjs.Install("/cookie_needed_echo", echo) if err != nil { log.Println(err) } cne.CookieNeeded = true gosockjs.Install("/close", closeSock) fmt.Println("Listening on port 8081") http.ListenAndServe("127.0.0.1:8081", new(NoRedirectServer)) }
func main() { paddr := flag.String("port", ":8082", "Port to serve on") flag.Parse() r := mux.NewRouter() r.HandleFunc("/static/{Filename:.*}", staticHandler) r.HandleFunc("/", handler) http.Handle("/", r) s, err := gosockjs.Install("/echo", echo) if err != nil { log.Fatal(err) } _ = s // s.WebsocketEnabled = false fmt.Printf("Listening on port %s\n", *paddr) if err := http.ListenAndServe(*paddr, nil); err != nil { log.Fatal(err) } }
func (s *Server) HandleHTTP(baseUrl string) { // The protocol is built on SockJS, so install SockJS handlers. gosockjs.Install(baseUrl, func(c *gosockjs.Conn) { s.sockjsHandler(c) }) }