reactor / reactor-netty

TCP/HTTP/UDP/QUIC client/server with Reactor over Netty
https://projectreactor.io
Apache License 2.0
2.58k stars 647 forks source link

Consider expanding the HttpClient to support a query parameter and fragment builders. #753

Open flyinprogrammer opened 5 years ago

flyinprogrammer commented 5 years ago

Today we make it super easy to create an HttpClient with headers that are set, or even conditionally set, for the lifetime of the HttpClient - which is super cool!

https://github.com/reactor/reactor-netty/blob/master/src/main/java/reactor/netty/http/client/HttpClient.java#L611-L624

However, there are cases where APIs use query parameters to achieve clever things. For example, (and I acknowledge this is weak) the Consul API allows (and now discourages) the use of an API security token to be passed to Consul via URI Query Parameter. Today, in order to support this we must use a delegate pattern and override the uri methods of an HttpClient class to inject the token.

If we had helper builder functions on the client, similar to the ones we have for headers, the delegate would be unnecessary.

Similarly a URI Fragment builder could also be added.

odravison commented 3 years ago

@violetagg , That is what I need. Do you know if still need help with this?

violetagg commented 3 years ago

@odravison we have uri(URI) isn't this helpful?

larry-cable commented 10 months ago

I agree with @flyinprogrammer it would be convenient if the HttpClient had a similar "builder" method for Headers or perhaps an overloaded uri() with a Map<String, String> of Query parameters that would be properly encoded and appended to the uri?