diff options
author | Valery Piashchynski <[email protected]> | 2021-05-29 00:24:30 +0300 |
---|---|---|
committer | Valery Piashchynski <[email protected]> | 2021-05-29 00:24:30 +0300 |
commit | fcda08498e8f914bbd0798da898818cd5d0e4348 (patch) | |
tree | 62d88384d07997e2373f3b273ba0cb83569ebced /plugins/http/channel.go | |
parent | 8f13eb958c7eec49acba6e343edb77c6ede89f09 (diff) |
- Add new internal plugin - channel. Which used to deliver messages from
the ws plugin to the http directly
Signed-off-by: Valery Piashchynski <[email protected]>
Diffstat (limited to 'plugins/http/channel.go')
-rw-r--r-- | plugins/http/channel.go | 28 |
1 files changed, 28 insertions, 0 deletions
diff --git a/plugins/http/channel.go b/plugins/http/channel.go new file mode 100644 index 00000000..42b73730 --- /dev/null +++ b/plugins/http/channel.go @@ -0,0 +1,28 @@ +package http + +import ( + "net/http" +) + +// messages method used to read messages from the ws plugin with the auth requests for the topics and server +func (p *Plugin) messages() { + for msg := range p.hub.ReceiveCh() { + p.RLock() + // msg here is the structure with http.ResponseWriter and http.Request + rmsg := msg.(struct { + RW http.ResponseWriter + Req *http.Request + }) + + p.handler.ServeHTTP(rmsg.RW, rmsg.Req) + + p.hub.SendCh() <- struct { + RW http.ResponseWriter + Req *http.Request + }{ + rmsg.RW, + rmsg.Req, + } + p.RUnlock() + } +} |