Skip to content

refactor: Fix deprecated gorilla/websocket change websocket.upgrade() to upgrader.upgrade() #58

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion chapter-D.3-golang-web-socket-chatting-app/go.mod
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,6 @@ module chapter-D.3
go 1.20

require (
github.com/gorilla/websocket v1.4.1
github.com/gorilla/websocket v1.5.3
github.com/novalagung/gubrak/v2 v2.0.0
)
4 changes: 2 additions & 2 deletions chapter-D.3-golang-web-socket-chatting-app/go.sum
Original file line number Diff line number Diff line change
Expand Up @@ -2,8 +2,8 @@ github.com/DefinitelyMod/gocsv v0.0.0-20181205141819-acfa5f112b45 h1:+OD9vawobD8
github.com/DefinitelyMod/gocsv v0.0.0-20181205141819-acfa5f112b45/go.mod h1:+nlrAh0au59iC1KN5RA1h1NdiOQYlNOBrbtE1Plqht4=
github.com/davecgh/go-spew v1.1.0 h1:ZDRjVQ15GmhC3fiQ8ni8+OwkZQO4DARzQgrnXU1Liz8=
github.com/davecgh/go-spew v1.1.0/go.mod h1:J7Y8YcW2NihsgmVo/mv3lAwl/skON4iLHjSsI+c5H38=
github.com/gorilla/websocket v1.4.1 h1:q7AeDBpnBk8AogcD4DSag/Ukw/KV+YhzLj2bP5HvKCM=
github.com/gorilla/websocket v1.4.1/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/gorilla/websocket v1.5.3 h1:saDtZ6Pbx/0u+bgYQ3q96pZgCzfhKXGPqt7kZ72aNNg=
github.com/gorilla/websocket v1.5.3/go.mod h1:YR8l580nyteQvAITg2hZ9XVh4b55+EU/adAjf1fMHhE=
github.com/novalagung/gubrak/v2 v2.0.0 h1:7wqp2XA2cLuTHyxVYw3AS+vRSfiwo8h3hmKxPFulOmA=
github.com/novalagung/gubrak/v2 v2.0.0/go.mod h1:zilliNLzP2RSdZ67Sz7NdqI4bg3j5zUTFR34tuXopA0=
github.com/pmezard/go-difflib v1.0.0 h1:4DBwDE0NGyQoBHbLQYPwSUPoCMWR5BEzIk/f1lZbAQM=
Expand Down
8 changes: 7 additions & 1 deletion chapter-D.3-golang-web-socket-chatting-app/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import (
"fmt"
"log"
"net/http"
"os"
"strings"

"github.com/gorilla/websocket"
Expand All @@ -18,6 +19,11 @@ const MESSAGE_LEAVE = "Leave"

var connections = make([]*WebSocketConnection, 0)

var upgrader = websocket.Upgrader{
ReadBufferSize: 1024,
WriteBufferSize: 1024,
}

type SocketPayload struct {
Message string
}
Expand Down Expand Up @@ -45,7 +51,7 @@ func main() {
})

http.HandleFunc("/ws", func(w http.ResponseWriter, r *http.Request) {
currentGorillaConn, err := websocket.Upgrade(w, r, w.Header(), 1024, 1024)
currentGorillaConn, err := upgrader.Upgrade(w, r, w.Header())
if err != nil {
http.Error(w, "Could not open websocket connection", http.StatusBadRequest)
}
Expand Down