Reputation: 11733
I'm using Akka and Play Mini (which is just a REST layer on top of Netty). I'm using it from Java. The syntax is simple, covered in their readme on GitHub:
@URL("/coco/*/name/*")
This is working fine, but means that all URLs will have to be only long paths. I found this thread that has some people claiming parameters are verboten and others saying they absolutely are not. I wish the play docs just stated their position, but alas. I am looking for the ability to support a url in the format of:
/search/query=dogs
Maybe the regular Play docs address this. Will keep searching..
Upvotes: 1
Views: 247
Reputation: 977
Maybe this will help other people.
@URL("/hello/*\\?*")
public static Result show() {
Map<String, String[]> queryString = request().queryString();
Map<String, String> data = new HashMap<String, String>();
for (String key : queryString.keySet()) {
for (String value : queryString.get(key)) {
data.put(key, value);
}
}
response().setContentType("text/html");
return ok(data.toString());
}
If you test with: curl "http://localhost:9000/hello/test?param1=0¶m2=yes"
The result will be:
test{param1=0, param2=yes}
Upvotes: 2