summaryrefslogtreecommitdiff
path: root/plugins/http/channel.go
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/http/channel.go')
-rw-r--r--plugins/http/channel.go28
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()
+ }
+}