Hi,
I want to create two different pathCalls where pathPattern prefix is same
e.g.
/v1/service/tag
/v1/service/tag?param1¶m2
Both of these should map to different ScalaMethodServiceCall .
Is this possible in some way?
Thanks.
Hi,
I want to create two different pathCalls where pathPattern prefix is same
e.g.
/v1/service/tag
/v1/service/tag?param1¶m2
Both of these should map to different ScalaMethodServiceCall .
Is this possible in some way?
Thanks.
Hi @akk1310,
No, this is not possible. You should see query strings params as optional params passed to a method.
The path to be matched in your case will always be /v1/service/tag
and the call will be forwarded to one and same ServiceCall
method.
param1
and param2
are params that can be available or not.
You should have one ServiceCall
that dispatches to the right internal method depending if params were passed or not.
Hi @octonato
Sorry to bother you with another doubt, I want to return different response types in both the cases,
i.e.
def getTag(param1,param2 ... Option[String]): ServiceCall[NotUsed, tagTypes] or
def getTag(param1,param2 ... Option[String]): ServiceCall[NotUsed, tags]
Is that possible by using same serviceCall ?
The only way to return different types in a typed API is to define a type hierarchy.
Like in:
trait Animal
class Dog extends Animal
class Cat extends Animal
def getSomeAnimal: Animal
getSomeAnimal
can return both Dogs
and Cats
. That’s not different when using the ServiceCall
API.