From 7ca7d0ed26ba80134cc8ed961ca4cad24248bcae Mon Sep 17 00:00:00 2001 From: Jack Murdock Date: Tue, 4 Dec 2018 13:46:55 -0800 Subject: [PATCH] adding webhook sending of full wrp message --- src/caduceus/outboundSender.go | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/caduceus/outboundSender.go b/src/caduceus/outboundSender.go index 6eab8e4a..d9389909 100644 --- a/src/caduceus/outboundSender.go +++ b/src/caduceus/outboundSender.go @@ -517,7 +517,22 @@ func (obs *CaduceusOutboundSender) worker(id int) { if now.After(dropUntil) { if now.Before(deliverUntil) { payload := msg.Payload - payloadReader := bytes.NewReader(payload) + var payloadReader *bytes.Reader + if obs.listener.Config.ContentType == "wrp" { + buffer := bytes.NewBuffer([]byte{}) + var f wrp.Format + switch msg.ContentType { + case "json": + f = wrp.JSON + default: + f = wrp.Msgpack + } + encoder := wrp.NewEncoder(buffer, f) + encoder.Encode(msg) + payloadReader = bytes.NewReader(buffer.Bytes()) + } else { + payloadReader = bytes.NewReader(payload) + } req, err := http.NewRequest("POST", obs.id, payloadReader) if nil != err { // Report drop