From d5af91c45325a30eb2ae8f123e747c12316d53f3 Mon Sep 17 00:00:00 2001 From: Brantley Harris Date: Mon, 14 May 2018 14:56:24 -0500 Subject: [PATCH] Fixed AMQP and AMQPS webhook endpoints to support namespaces. --- pkg/endpoint/endpoint.go | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pkg/endpoint/endpoint.go b/pkg/endpoint/endpoint.go index 244d3705..6c60ec65 100644 --- a/pkg/endpoint/endpoint.go +++ b/pkg/endpoint/endpoint.go @@ -469,6 +469,7 @@ func parseEndpoint(s string) (Endpoint, error) { // Basic AMQP connection strings in HOOKS interface // amqp://guest:guest@localhost:5672//?params=value + // or amqp://guest:guest@localhost:5672///?params=value // // Default params are: // @@ -486,8 +487,15 @@ func parseEndpoint(s string) (Endpoint, error) { endpoint.AMQP.Durable = true endpoint.AMQP.DeliveryMode = amqp.Transient - // Bind queue name - if len(sp) > 1 { + // Fix incase of namespace, e.g. example.com/namespace/queue + // but not example.com/queue/ - with an endslash. + if len(sp) > 2 && len(sp[2]) > 0 { + endpoint.AMQP.URI = endpoint.AMQP.URI + "/" + sp[1] + sp = append([]string{endpoint.AMQP.URI}, sp[2:]...) + } + + // Bind queue name with no namespace + if len(sp) > 1 { var err error endpoint.AMQP.QueueName, err = url.QueryUnescape(sp[1]) if err != nil {