summaryrefslogtreecommitdiff
path: root/plugins/http
diff options
context:
space:
mode:
Diffstat (limited to 'plugins/http')
-rw-r--r--plugins/http/channel.go5
-rw-r--r--plugins/http/plugin.go7
2 files changed, 6 insertions, 6 deletions
diff --git a/plugins/http/channel.go b/plugins/http/channel.go
index 42b73730..23b5ff3e 100644
--- a/plugins/http/channel.go
+++ b/plugins/http/channel.go
@@ -6,7 +6,7 @@ import (
// 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() {
+ for msg := range p.hub.ToWorker() {
p.RLock()
// msg here is the structure with http.ResponseWriter and http.Request
rmsg := msg.(struct {
@@ -14,9 +14,10 @@ func (p *Plugin) messages() {
Req *http.Request
})
+ // invoke handler with redirected responsewriter and request
p.handler.ServeHTTP(rmsg.RW, rmsg.Req)
- p.hub.SendCh() <- struct {
+ p.hub.FromWorker() <- struct {
RW http.ResponseWriter
Req *http.Request
}{
diff --git a/plugins/http/plugin.go b/plugins/http/plugin.go
index 38b3621f..397de7ae 100644
--- a/plugins/http/plugin.go
+++ b/plugins/http/plugin.go
@@ -75,7 +75,7 @@ type Plugin struct {
// Init must return configure svc and return true if svc hasStatus enabled. Must return error in case of
// misconfiguration. Services must not be used without proper configuration pushed first.
-func (p *Plugin) Init(cfg config.Configurer, rrLogger logger.Logger, server server.Server, channel channel.Hub) error {
+func (p *Plugin) Init(cfg config.Configurer, rrLogger logger.Logger, server server.Server, hub channel.Hub) error {
const op = errors.Op("http_plugin_init")
if !cfg.Has(PluginName) {
return errors.E(op, errors.Disabled)
@@ -109,9 +109,7 @@ func (p *Plugin) Init(cfg config.Configurer, rrLogger logger.Logger, server serv
p.cfg.Env[RrMode] = "http"
p.server = server
- p.hub = channel
-
- go p.messages()
+ p.hub = hub
return nil
}
@@ -128,6 +126,7 @@ func (p *Plugin) logCallback(event interface{}) {
// Serve serves the svc.
func (p *Plugin) Serve() chan error {
errCh := make(chan error, 2)
+ go p.messages()
// run whole process in the goroutine
go func() {
// protect http initialization