If your are using the snail built-in game module. then:
Define a extension(struct), embedding GameExtensionSupport and implement IGameExtension.
You can call the function SetRequestHandler, SetRequestHandlerBinary, SetRequestHandlerJson or SetRequestHandlerObject to associate a protocol response logic.
Finish the protocol response logic said above.
Implement other interfaces if your need: IGoroutineExtension、IBeforeRequestExtension、IAfterRequestExtension and so on.
Call the function "RegisterExtension" in the package "github.com/xuzhuoxi/snail/module/internal/game/ifc" to register your extension go game module. Maybe like that: