-
Notifications
You must be signed in to change notification settings - Fork 1.2k
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
[websocket] Add a config to reject initial connection #750
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -12,7 +12,7 @@ import ( | |
|
||
"github.com/99designs/gqlgen/graphql" | ||
"github.com/gorilla/websocket" | ||
"github.com/hashicorp/golang-lru" | ||
lru "github.com/hashicorp/golang-lru" | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 🤔 There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. My IDE linter does this automatically 😬 |
||
"github.com/vektah/gqlparser" | ||
"github.com/vektah/gqlparser/ast" | ||
"github.com/vektah/gqlparser/gqlerror" | ||
|
@@ -94,6 +94,14 @@ func (c *wsConnection) init() bool { | |
} | ||
} | ||
|
||
if c.cfg.websocketInitFunc != nil { | ||
if err := c.cfg.websocketInitFunc(c.ctx, c.initPayload); err != nil { | ||
c.sendConnectionError(err.Error()) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. The server now has the option to return an error. The error body is then sent to the client |
||
c.close(websocket.CloseNormalClosure, "terminated") | ||
return false | ||
} | ||
} | ||
|
||
c.write(&operationMessage{Type: connectionAckMsg}) | ||
case connectionTerminateMsg: | ||
c.close(websocket.CloseNormalClosure, "terminated") | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Updated the interface to return
error
instead ofbool