~juju-qa/ubuntu/yakkety/juju/juju-1.25.8

« back to all changes in this revision

Viewing changes to src/golang.org/x/net/websocket/examplehandler_test.go

  • Committer: Nicholas Skaggs
  • Date: 2016-12-02 17:28:37 UTC
  • Revision ID: nicholas.skaggs@canonical.com-20161202172837-jkrbdlyjcxtrii2n
Initial commit of 1.25.6

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
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
 
 
5
package websocket_test
 
6
 
 
7
import (
 
8
        "io"
 
9
        "net/http"
 
10
 
 
11
        "golang.org/x/net/websocket"
 
12
)
 
13
 
 
14
// Echo the data received on the WebSocket.
 
15
func EchoServer(ws *websocket.Conn) {
 
16
        io.Copy(ws, ws)
 
17
}
 
18
 
 
19
// This example demonstrates a trivial echo server.
 
20
func 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
}