Skip to content
Advertisement

Tag: gorilla

How to properly refuse websocket upgrade request?

Sometimes I want to refuse a http client’s request to upgrade connection to websocket. Code (using go’s Gin and gorilla/websocket framework:) To allow upgrade: To refuse upgrade (due to invalid request params): Explaination: Here to refuse the upgrade I just return a http 400 code, then terminate the connection, and didn’t do the upgrade at all. The issue The problem

Advertisement