1// Copyright 2012 The Go Authors. All rights reserved.
2// Use of this source code is governed by a BSD-style
3// license that can be found in the LICENSE file.
4
5package websocket_test
6
7import (
8	"io"
9	"net/http"
10
11	"golang.org/x/net/websocket"
12)
13
14// Echo the data received on the WebSocket.
15func EchoServer(ws *websocket.Conn) {
16	io.Copy(ws, ws)
17}
18
19// This example demonstrates a trivial echo server.
20func ExampleHandler() {
21	http.Handle("/echo", websocket.Handler(EchoServer))
22	err := http.ListenAndServe(":12345", nil)
23	if err != nil {
24		panic("ListenAndServe: " + err.Error())
25	}
26}
27