Skip to content

Commit

Permalink
fix: trim white space from routing keys
Browse files Browse the repository at this point in the history
  • Loading branch information
marianozunino committed Oct 11, 2024
1 parent 84cd146 commit 317d018
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions internal/app.go
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import (
"fmt"
"log"
"os"
"strings"

"github.com/fatih/color"
"github.com/marianozunino/goq/internal/config"
Expand Down Expand Up @@ -105,11 +106,13 @@ func handleError(msg string, err error) error {

// Helper function to bind the temporary queue to routing keys
func bindQueueToRoutingKeys(consumer *rmq.Consumer, queueName string, routingKeys []string) error {
color.Green("Binding queue %q to routing keys", queueName)
for _, routingKey := range routingKeys {
if err := consumer.BindQueue(queueName, routingKey); err != nil {
return handleError(fmt.Sprintf("failed to bind queue %s to routing key %s", queueName, routingKey), err)
routingKeyTrimmed := strings.TrimSpace(routingKey)
if err := consumer.BindQueue(queueName, routingKeyTrimmed); err != nil {
return handleError(fmt.Sprintf("failed to bind queue %q to routing key %q", queueName, routingKeyTrimmed), err)
}
color.Green("Binding queue %s to routing key %s", queueName, routingKey)
color.Yellow("Bound routing key %q", routingKeyTrimmed)
}
return nil
}
Expand Down

0 comments on commit 317d018

Please sign in to comment.