anterofit
anterofit copied to clipboard
Base URL doesn’t do what it’s supposed to
I’m very new to Rust so maybe I’m misunderstanding something, but I have a feeling the base URL logic isn’t quite right.
My initial understanding was that specifying the base URL would automatically put all of the URLs in the service’s methods under its namespace, e.g. so if the base URL is "/rest/v1"
and the method has GET("/test")
, the resulting URL would be /rest/v1/test
. However, since you use Url::join
for this purpose, the leading slash in the method’s URL acts as an absolute path signifier, resetting the URL to /test
. If I remove this leading slash, it still doesn’t work as expected since the base URL doesn’t have a trailing slash, so Url::join
removes the trailing path component and then appends the other URL, resulting in /rest/test
. While this makes sense for URLs in general, I find this quite confusing in this context and counter-intuitive. My current work-around was to drop the path from the base URL and to add .chain_interceptor(PrependUrl("/rest/v1"))
to the Adapter
builder chain.
Would you consider changing the implementation to avoid this confusing behaviour?
Thanks!