0

While defining a client interface is there a way to pass a map of Query parameters? I know I can do a single via:

@Client("MyApi)
interface Zoo { 

  fun fetchAnimals(@QueryValue color : String) : String 
  
}

But, how would a add a variable map of parameters?

@Client
interface Zoo { 

  fun fetchAnimals(@QueryMap color : Map<String,String>) : String 
  
}

@QueryMap is from retrofit but I can't figure out an equivalent in micronaut or another workaround?

Kurt
  • 399
  • 3
  • 14

1 Answers1

1

6.4 Simple Request Binding : Binding from Multiple Query values

Binding from Multiple Query values Instead of binding from a single section of the request, it may be desirable to bind all query values for example to a POJO. This can be achieved by using the exploded operator (?pojo*) in the URI template.

For example:

@Client("/")
interface Zoo { 

  @Get("{?colors*}")
  fun fetchAnimals(@QueryValue colors : Map<String,Any>) : String 
  
}
ShingJo
  • 614
  • 1
  • 7