Skip to content
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

Allow default data on request (query params, headers, payload) #315

Open
FreifeldRoyi opened this issue Jun 7, 2021 · 2 comments
Open
Labels

Comments

@FreifeldRoyi
Copy link

(Continuing a conversation with @andymc12 from Gitter channel)
I would like to create requests with default data with no extra parameters. Headers are already provided with RegisterClientHeaders but QueryParam and actual JSON payloads are not implemented:

e.g

// instead of 
@Get("/")
SomeObject fetchItems(@QueryParam("asd") String myParam);

// use something like:
@Get("/")
@DefaultQueryParam(name="asd", value="my-val")
SomeObject fetchItems();

// or:
@Get("/")
@RegisterClientParams(QueryParamsProvider.class)
SomeObject fetchItems();

// or some other idea =)

Same thing goes for actual json payload

@jamezp
Copy link
Contributor

jamezp commented Feb 12, 2024

Given we cannot find the Gitter history, could you explain more some more details of the issue? Would using something like @QueryParam("asd") @DefaultValue("my-val") not work here?

@FreifeldRoyi
Copy link
Author

FreifeldRoyi commented Jun 19, 2024

Hi @jamezp.
I think that @DefauleValue("my-val") would partially help.
When I originally posted on Gitter, @andymc12 said that it is not portable and not part of the standard. I'm not sure if it is now.
Here's a link to the Gitter history

If I understand what I meant, since it was a long time ago - I suggested 2 options:

  1. Simple way with @DefaultValue or @DefaultQueryParam
  2. I think it's like RegisterHeaderParams where there's a class that can somehow calculate the required data and return it to the function. Not sure when I would use it though 🤷🏼‍♂️

Would be awesome to do the same thing for payload as well

At that time, as far as I remember, I needed to set the headers, query params, payload, path params in one single function call. It created a telescopic function. Also, most of the time, I needed the same things over and over again, so writing them down in several places in my code just didn't look good.
So I had to wrap it with another client, and I think it just beats the purpose of creating a standard way of handling REST clients

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

3 participants