Is it possible to have two different pathCalls with same pathPatteren prefix?


I want to create two different pathCalls where pathPattern prefix is same


Both of these should map to different ScalaMethodServiceCall .

Is this possible in some way?


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.

Thanks @octonato

It cleared my doubt.

Hi @octonato

Sorry to bother you with another doubt, I want to return different response types in both the cases,

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.

Thanks @octonato

It worked.

It led me to learn custom serializes as well. :slight_smile: