What happened?
The readme suggests I can use Dialogue to call non-Conjure servers, but I've run into a bit of trouble: https://github.com/palantir/dialogue/tree/96ae91db83aa9ccdc5939a934ab84b33691ec240#dialogue-annotations-processor-generated-client-bindings
Internally, Dialogue passes paths around as a list of segments, throwing away information about whether or not a trailing slash exists:
|
public interface HttpPath { |
This results in the server issuing a 301 redirect to the path ending in a slash. However, the Apache client is configured to ignore redirects:
|
.setRedirectsEnabled(false) |
I thought about implementing a channel to handle the 301 and resubmit the request with the slash, but I think the Channel API is too high-level since it also talks in terms of UrlBuilders, and therefore path segments.
It also seems there's a lot of logic wrapped up in ApacheHttpClientChannels.ClientBuilder that I don't (or can't, due to being package-private) want to replicate to enable redirects on the Apache client.
What did you want to happen?
I think I agree with the principle of no redirects, so it perhaps makes sense to support trailing slashes rather than 301s in this case?
My proposal might be to have HttpPath capture whether or not there exists a trailing slash (special-casing trailing slashes, vs any other duplicate slashes in the path). PathTemplate can then have a method to append a slash, templated in to the generated classes by the EndpointsEnumGenerator.
Unfortunately, I imagine this could be a breaking change for anyone relying on the current path template parsing behaviour...
What happened?
The readme suggests I can use Dialogue to call non-Conjure servers, but I've run into a bit of trouble: https://github.com/palantir/dialogue/tree/96ae91db83aa9ccdc5939a934ab84b33691ec240#dialogue-annotations-processor-generated-client-bindings
Internally, Dialogue passes paths around as a list of segments, throwing away information about whether or not a trailing slash exists:
dialogue/dialogue-annotations-processor/src/main/java/com/palantir/dialogue/annotations/processor/data/HttpPath.java
Line 23 in c8c1a7f
This results in the server issuing a 301 redirect to the path ending in a slash. However, the Apache client is configured to ignore redirects:
dialogue/dialogue-apache-hc5-client/src/main/java/com/palantir/dialogue/hc5/ApacheHttpClientChannels.java
Line 547 in dffea94
I thought about implementing a channel to handle the 301 and resubmit the request with the slash, but I think the Channel API is too high-level since it also talks in terms of UrlBuilders, and therefore path segments.
It also seems there's a lot of logic wrapped up in ApacheHttpClientChannels.ClientBuilder that I don't (or can't, due to being package-private) want to replicate to enable redirects on the Apache client.
What did you want to happen?
I think I agree with the principle of no redirects, so it perhaps makes sense to support trailing slashes rather than 301s in this case?
My proposal might be to have HttpPath capture whether or not there exists a trailing slash (special-casing trailing slashes, vs any other duplicate slashes in the path). PathTemplate can then have a method to append a slash, templated in to the generated classes by the EndpointsEnumGenerator.
Unfortunately, I imagine this could be a breaking change for anyone relying on the current path template parsing behaviour...