Encoding url's the Play! Framework

Is there a way to make the Play! Framework ignore slashes and ? in parts of the URL?

Typically, if I have the following:

www.123.com/api/link/http:www.bla.com/?contenId=123&User=test

It won't work. In that case, what I would want to do is simply have the link in the last part of the URL in a String variable to save it. I suppose I can force the client to replace the / and ? by something else, but I would rather keep it simple.

My first thought was that maybe there is a way to configure the routing such that we have something like:

/api/link/{data}

where data would hold whatever remains of the URL. Can't find out how to do that though.

Answers


You can't have : / ? except your main URL. You should encode your parameter to append it to main URL. See URLEncoder for Java.

This is not a valid URL:

http://www.123.com/api/link/http://www.bla.com/?contenId=123&User=test

It must be:

http://www.123.com/api/link/http%3a%2f%2fwww.bla.com%2f%3fcontenId%3d123%26User%3dtest

Then you can pass it to {data} parameter and decode it in your handler method.


Need Your Help

How to use custom directive in a T4 template?

visual-studio-2008 .net-3.5 c#-3.0 t4

I created a custom T4 directive processor in one project, and now I want to use the processor in a T4 template in another project, but I'm receiving the following error:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.