Skip to content

Commit

Permalink
Making Websocket Local read-write
Browse files Browse the repository at this point in the history
  • Loading branch information
supagroova committed Jul 6, 2023
1 parent b9547c4 commit 0b39f1d
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions websocket/websocket.go
Original file line number Diff line number Diff line change
Expand Up @@ -172,8 +172,12 @@ func releaseConn(conn *Conn) {

// Locals makes it possible to pass interface{} values under string keys scoped to the request
// and therefore available to all following routes that match the request.
func (conn *Conn) Locals(key string) interface{} {
return conn.locals[key]
func (conn *Conn) Locals(key string, value ...interface{}) interface{} {
if len(value) == 0 {
return conn.locals[key]
}
conn.locals[key] = value[0]
return value[0]
}

// Params is used to get the route parameters.
Expand Down

0 comments on commit 0b39f1d

Please sign in to comment.