1

Can I use Map in query params? I have a number of resources for REST and I want to change list of query params in one place, I have a such source:

@GET
@Path("...")
@Produces({MediaType.APPLICATION_JSON})
public String getPath(
        @PathParam("...") String path, 
        @QueryParam("headers") Map<String, String> headers // error!

How to use dynamic list of query params? Because headers will change in the future

mystdeim
  • 4,802
  • 11
  • 49
  • 77
  • and what is the error? But this might help: http://stackoverflow.com/questions/2745265/is-listdog-a-subclass-of-listanimal-why-arent-javas-generics-implicitly-p – Tom Jul 21 '16 at 13:39

1 Answers1

0

From Oracle's documentation on extracting request parameters, you should be able to use the @Context annotation to pass headers into your method:

@GET
@Path("...")
@Produces({MediaType.APPLICATION_JSON})
public String getPath(
    @PathParam("...") String path, 
    @Context HttpHeaders headers) {
...

and then access the headers and cookies via methods on the HttpHeaders instance. I haven't tried this, but it looks like it should work.