mirror of https://github.com/gorilla/websocket.git
Updated docs.
This commit is contained in:
parent
0a7cd15dd1
commit
ecf9b98e31
15
doc.go
15
doc.go
|
@ -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)
|
||||||
|
|
|
@ -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) {
|
||||||
|
|
Loading…
Reference in New Issue