odolbeau / rabbit-mq-admin-toolkit

Manage a RabbitMQ cluster easily.
MIT License
84 stars 28 forks source link

Url encoding of vhost #37

Open romainjanvier opened 6 years ago

romainjanvier commented 6 years ago

I met an issue with the command to create queues. I have two vhosts in my application : / and /module. Then I made the configuration file with these two vhosts, here a sample :

/:
    exchanges:
        direct:
            type: direct
            durable: true
    queues:
        jobs_image:
            durable: true
            bindings:
                -
                    exchange: direct
                    routing_key: jobs_image

/module:
    exchanges:
        direct:
            type: direct
            durable: true
    queues:
        jobs_image:
            durable: true
            bindings:
                -
                    exchange: direct
                    routing_key: jobs_image

I realized the command is not able to manage 2 vhosts in the same file (unfortunately...), anyway, I split this configuration into two files.

But the execution of the queues creation command with the vhost /module didn't work because of the leading slash. I was able to make work the command naming vhost %2fmodule. But there is no need to url rewrite the default vhost thanks to this code : https://github.com/odolbeau/rabbit-mq-admin-toolkit/blob/master/src/Bab/RabbitMq/VhostManager.php#L21

Although leading slash is not required in the rabbitmq vhost name, many usage include it. So I ask why there is no url rewriting on every vhost name or is it intentional as the code seems to mean ?

Thanks for your great shared work.

odolbeau commented 6 years ago

Hi.

You don't need to put it in your configuration file nor in the command name (you can use directly module in your example). Anyway, you're right, we could definitively transform / remove the leading slash when we found one. This will allow everyone to use either a slash, %2f or nothing. Of course, don't hesitate to create a PR if you want. :)