I'm using Restlet to make a RESTful platform. I haven't used it before, but I decided to use 2.0 because it is better to start with the latest and greatest technology, right?
The key thing I am looking for is the ability to have someone to put in a URL like http://mysite/New%20York/3
and have the service respond with something like [New York,New York,New York]
, so I need to pass in request attributes. Using this post for Restlet 1.1 (because I can't seem to find any documentation for this on the Restlet site), I wired up my application like so:
router.attach("{text}/{count}", RepeaterResource.class);
The new way to do this is apparently in the UniformResource#doInit()
method, so mine looks like (without error checking):
@Override
public void doInit()
{
magicText = "" + getRequestAttributes().get("text");
repeatAmount = Integer.parseInt("" + getRequestAttributes().get("count"));
}
The problem is that the Map<String, Object>
returned from getRequestAttributes()
is always completely empty! This seems rather odd. Am I wiring the routing up wrong?
Of course, I could just use getQuery()
and parse it myself, but that is definitely the wrong way to go about doing this and it seems like there should be an easy way to do this (similar to the way previous versions worked).