Re: Add a get parameter to all routes without pattern

65 views
Skip to first unread message

James Roper

unread,
Oct 7, 2012, 8:58:46 PM10/7/12
to play-fr...@googlegroups.com
RequestHeader.queryString returns a Map of query parameter names to lists of values.  You can access all parameters there.

On Saturday, 6 October 2012 01:16:30 UTC+10, Greg wrote:
Hello, 

I have a Play 2.0 framework that is working well and I want to be able to add a specific get parameter (known only by be) to all routes. That parameters should be ignore by routes.

I explain.
Suppose I have routes like :

GET     /add/:id              controllers.MyController.add(id : Int)
GET     /remove/:id           controllers.MyController.remove(id : Int)

What I want is, for example, that http://mydomain.com/add/77?mySecretParam=ok still goes to controllers.MyController.add(id : Int) and then I could get mySecretParam in request object. And the same for all my routes.

Do you have any idea how can I do ?

Thanks.
Greg

Vincent Buzzano

unread,
Oct 8, 2012, 5:02:53 PM10/8/12
to play-fr...@googlegroups.com

you should be able to use parameters in query string without add them to route

eg :
http://mydomain.com/add/77? mySecretParam=ok

it will call this route
GET /add/:id controllers.MyController.add( id : Int)

Le 8 oct. 2012 15:44, "Greg" <gregl...@gmail.com> a écrit :
Hello, 

Thanks for your answer. I know I can to that. But if I do not add mySecretParam to all my routes in route file, Play won't be happy. And I want to avoid adding that parameter to all my routes.

--
You received this message because you are subscribed to the Google Groups "play-framework" group.
To view this discussion on the web visit https://groups.google.com/d/msg/play-framework/-/BOllS1tLC_QJ.
To post to this group, send email to play-fr...@googlegroups.com.
To unsubscribe from this group, send email to play-framewor...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/play-framework?hl=en.
Reply all
Reply to author
Forward
0 new messages