-
Notifications
You must be signed in to change notification settings - Fork 38.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Support HttpRequestValues as a method parameter for HTTP Interface #34227
Comments
If you want something in between like a dedicated |
Yes, I did not find anything else used for HTTP interfaces.
But it does not work that way though, at least from what I can see. There does not exist any methods on
This is what this issue is requesting from Spring Framework. To provide the ability to provide an object ( |
Sorry, my bad. It doesn't make sense to pass RequestEntity into RestClient as the two provide a similar API for building the request. RequestEntity is useful to provide a similar experience with the RestTemplate. We could support RequestEntity as an argument, but the main value of an HTTP interface is to indicate the inputs required for the endpoint. If you generalize that how would does user has to know what to pass? If you generalize it all the way into RequestEntity then what value do you get for an HTTP interface? |
When an API requires multiple values, the number of arguments for HTTP service method can be a bit painful. For example:
The service method can be simplified to:
Which is better, but I think it would be easier or nicer even to allow a single argument that encapsulates all of the request details.
That argument could also override the predefined ones such as the
consumes
orpath
from the exchange annotation. This is more or less whatUriBuilderFactory
does today for the URL.If I'm not mistaken,
RestTemplate
provided something similar throughRequestEntity
.Note I know that you can drop down to the 'lower level'
RestClient
to fully customize the request as indicated in this table in the documentation. But providing that control at the HTTP interface level I think will be a welcome addition.Looking at Framework's code,
HttpServiceArgumentResolver
is responsible for consuming the various annotations and applying those values toHttpRequestValues
. So aHttpServiceArgumentResolver
that accepts aHttpRequestValues
or similar may work I think.My company has variety of modern and legacy APIs and Web services. While we try to conform to some standard when modernizing legacy services or APIs, there still exists APIs that require a lot of information in their request.
To work around this, I started wrapping the request details into an intermediary object and then delegate to the service method. This leads to cleaner code (IMO). For example:
The text was updated successfully, but these errors were encountered: