1

I'm looking for the best way to access route parameters from within a custom action composition. I found some answers from a couple of years ago suggesting it was not possible in Java then but wanted to know if anything had changed since then.

Previous Question

I'm wanting to write some middleware that needs to be able to get the route params. If there is no out of the box way, is there any possible workarounds?

In Java preferably

Adam
  • 29
  • 6

1 Answers1

0

Depending on: https://stackoverflow.com/a/38919004/7394957

In play 2.7 the structure of context and request has been changed. So instead of getting the routing information from

context.request().args.get("ROUTE_PATTERN") 

you can get it from the request typed attr directly:

String routePattern = req.attrs().get(Router.Attrs.HANDLER_DEF).path(); 

That can be passed to the RouteExtractor from Akinniranye James Ayodele.

Simon
  • 1
  • 3