-1

I need a service call which has two query parameters. One with a default hardcoded value and other the user would supply. I tried creating :

ServiceCall<NotUsed, String> randomCall(String abc)

using restCall(Method.GET, "/testing?a=something&abc", this::randomCall)

But received IllegalArgumentException. Is there any way to do this in Lagom?

Sajit Gupta
  • 98
  • 1
  • 6
  • Any particular reason you want to have a hardcoded query param? If it's a _query_ param, it should be variable, shouldn't it? – erip May 17 '18 at 12:14
  • If you want this kind of behavior, I'd probably put the query string _after_ the hardcoded param. – erip May 17 '18 at 12:20

1 Answers1

2

You can have optional query parameters like so:

ServiceCall<NotUsed, String> randomCall(Optional<String> a, String abc)

restCall(Method.GET, "/testing?a&abc", this::randomCall)

This allows you to handle the case if a is not defined in your implementation, in your case using a default value.

Johnneh
  • 247
  • 1
  • 10