Skip to content

Commit

Permalink
Merge pull request #14 from Comcast/feature/add-auth-msg
Browse files Browse the repository at this point in the history
Update to the latest webpa-common code and update accordingly.
  • Loading branch information
schmidtw committed Aug 11, 2017
2 parents b5a8f10 + 2569bc6 commit 5810e51
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 20 deletions.
6 changes: 3 additions & 3 deletions src/glide.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion src/glide.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ package: .
homepage: https://github.com/Comcast/talaria
import:
- package: github.com/Comcast/webpa-common
version: 71a8464dd17e855b29b904b64bc928b31370224f
version: ae4ce7815a4dc6a3d982f6aee96619da71ffc358
subpackages:
- device
- logging
Expand Down
35 changes: 19 additions & 16 deletions src/talaria/dispatcher.go
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ import (

"github.com/Comcast/webpa-common/device"
"github.com/Comcast/webpa-common/logging"
"github.com/Comcast/webpa-common/wrp"
)

// outboundEnvelope is a tuple of information related to handling an asynchronous HTTP request
Expand Down Expand Up @@ -140,22 +141,24 @@ func (d *dispatcher) OnDeviceEvent(event *device.Event) {
return
}

var (
destination = event.Message.To()
contentType = event.Format.ContentType()
)

if strings.HasPrefix(destination, EventPrefix) {
eventType := destination[len(EventPrefix):]
if err := d.dispatchEvent(eventType, contentType, event.Contents); err != nil {
d.logger.Error("Error dispatching event [%s]: %s", destination, err)
}
} else if strings.HasPrefix(destination, DNSPrefix) {
unfilteredURL := destination[len(DNSPrefix):]
if err := d.dispatchTo(unfilteredURL, contentType, event.Contents); err != nil {
d.logger.Error("Error dispatching to [%s]: %s", destination, err)
if routable, ok := event.Message.(wrp.Routable); ok {
var (
destination = routable.To()
contentType = event.Format.ContentType()
)

if strings.HasPrefix(destination, EventPrefix) {
eventType := destination[len(EventPrefix):]
if err := d.dispatchEvent(eventType, contentType, event.Contents); err != nil {
d.logger.Error("Error dispatching event [%s]: %s", destination, err)
}
} else if strings.HasPrefix(destination, DNSPrefix) {
unfilteredURL := destination[len(DNSPrefix):]
if err := d.dispatchTo(unfilteredURL, contentType, event.Contents); err != nil {
d.logger.Error("Error dispatching to [%s]: %s", destination, err)
}
} else {
d.logger.Error("Unable to route to [%s]", destination)
}
} else {
d.logger.Error("Unable to route to [%s]", destination)
}
}

0 comments on commit 5810e51

Please sign in to comment.