Skip to content
Node: wsgithub.com/sahilkhaire/gox/ws

Conn.Upgrade

Overview

Upgrade upgrades the HTTP request on w/r using up (nil uses DefaultUpgrader).

Part of the ws package — Node.js analog: ws.

Method on Conn — call it on a value of that type after constructing or receiving one from a constructor.

Signature

go
func Upgrade(w http.ResponseWriter, r *http.Request, up *Upgrader) (*Conn, error)

Compare: Node.js · Standard Go · gox

js
// Typical ws pattern in Node.js
go
// gorilla/websocket Upgrader or Dialer
go
import "github.com/sahilkhaire/gox/ws"

conn, err := upgrader.Upgrade(w, r, nil)

Example

go
import "github.com/sahilkhaire/gox/ws"

conn, err := upgrader.Upgrade(w, r, nil)

Tips

Obtain a Conn value first (see constructors on the package overview), then call Upgrade.

Standard library alternative

gox wraps the Go standard library or a trusted dependency with Node-familiar naming. You can use the underlying library directly — see the package overview for escape hatches.

Back to ws package overview

MIT Licensed · Built for Node.js developers moving to Go