EasyNetQ.Management.Client icon indicating copy to clipboard operation
EasyNetQ.Management.Client copied to clipboard

Bug: Url with path prefix throws an regex error

Open stpag-cv opened this issue 5 years ago • 1 comments

Hi,

the management api is usually available at scheme://host:port/api/... But it is also desirable (and possible) to set a different path (e.g. for reverse proxy scenarios). This is supported by RabbitMQs "path prefix" option.

Unfortunately EasyNetQ does not support it, see ManagementClient:

var uri = new Uri($"{HostUrl}:{PortNumber}/api/{path}{query ?? string.Empty}");

Using this code snippet also throws an ArgumentException of "hostUrl is illegal":

var initial = new ManagementClient("http://localhost/management/", "guest", "guest");

The solution for this may be straight forward: accept a valid url (including scheme, host, port, path and query parameters) in class ManagementClient and inject the REST api + new query parameters required for the rest call.

This way, the api can be fine tuned with all available options and it may also be possible to tweak the api calls in the future to circumvent a breaking api change in rabbitmq.

Best stpag-cv

stpag-cv avatar Mar 09 '20 15:03 stpag-cv

I think that would be a nice addition if implemented with backwards compatibility, are you willing to create a PR for this?

zidadrtl avatar Mar 10 '20 16:03 zidadrtl

https://www.nuget.org/packages/EasyNetQ.Management.Client/2.0.0-beta7

Pliner avatar Dec 13 '22 15:12 Pliner