Updated docs.

This commit is contained in:
Joachim Bauch 2014-04-18 00:40:10 +02:00
parent 0a7cd15dd1
commit ecf9b98e31
2 changed files with 12 additions and 7 deletions

15
doc.go
View File

@ -6,14 +6,19 @@
// //
// Overview // Overview
// //
// The Conn type represents a WebSocket connection. A server application calls // The Conn type represents a WebSocket connection. A server application uses
// the Upgrade function from an HTTP request handler to get a pointer to a // the Upgrade function from an Upgrader object with a HTTP request handler
// Conn: // to get a pointer to a Conn:
//
// var upgrader = websocket.Upgrader{
// ReadBufferSize: 1024,
// WriteBufferSize: 1024,
// }
// //
// func handler(w http.ResponseWriter, r *http.Request) { // func handler(w http.ResponseWriter, r *http.Request) {
// conn, err := websocket.Upgrade(w, r, nil, 1024, 1024) // conn, err := upgrader.Upgrade(w, r, nil)
// if _, ok := err.(websocket.HandshakeError); ok { // if _, ok := err.(websocket.HandshakeError); ok {
// http.Error(w, "Not a websocket handshake", 400) // ... an error message already has been sent.
// return // return
// } else if err != nil { // } else if err != nil {
// log.Println(err) // log.Println(err)

View File

@ -191,8 +191,6 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
return c, nil return c, nil
} }
// This method is deprecated, use websocket.Upgrader instead.
//
// Upgrade upgrades the HTTP server connection to the WebSocket protocol. // Upgrade upgrades the HTTP server connection to the WebSocket protocol.
// //
// The application is responsible for checking the request origin before // The application is responsible for checking the request origin before
@ -220,6 +218,8 @@ func (u *Upgrader) Upgrade(w http.ResponseWriter, r *http.Request, responseHeade
// If the request is not a valid WebSocket handshake, then Upgrade returns an // If the request is not a valid WebSocket handshake, then Upgrade returns an
// error of type HandshakeError. Applications should handle this error by // error of type HandshakeError. Applications should handle this error by
// replying to the client with an HTTP error response. // replying to the client with an HTTP error response.
//
// This method is deprecated, use websocket.Upgrader instead.
func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header, readBufSize, writeBufSize int) (*Conn, error) { func Upgrade(w http.ResponseWriter, r *http.Request, responseHeader http.Header, readBufSize, writeBufSize int) (*Conn, error) {
u := Upgrader{ReadBufferSize: readBufSize, WriteBufferSize: writeBufSize} u := Upgrader{ReadBufferSize: readBufSize, WriteBufferSize: writeBufSize}
u.Error = func(w http.ResponseWriter, r *http.Request, status int, reason error) { u.Error = func(w http.ResponseWriter, r *http.Request, status int, reason error) {