Hello, I am using restlet to make GAE app that exposes a RESTful API.
My basic problem is how to express relations in the API. *Details:* There exists a collection at /user/tools that contains items of several types. To user GET on /user/tools should give: http://me.com/hammers/1 http://me.com/saws/34 etc... On the server these items are referred to by Keys that are basically (Type, Id), used in the persistence layer. So a Tools collection will a Keys array: [(Hammer, 1), (Saw, 34)] *The problem:* Now I have to translate from Key to Url every time I encode one of these objects to JSON and every time I decode JSON to one of these objects. (Lets say the collection got updated and the client just give me a bunch of new URLs.) To this end I've extended JacksonRepresentation to add encoder and decoder for the Key.class. The key to URL mapping is handled for those KeyType to URL relations that have been registered ahead of time. However... *When encoding:* I don't have access to the request object, therefore there is no good way to set the host part of the URL. I could make it an application property, but that seems like a bad idea. *When decoding:* There is no technical problem, but it seems like I should be asking the ServerResource to decode the URL into a Key, if applicable, and not be relying on additional mapping. *Summary:* I would like to link some prescience layer identifier to URL and vise versa. (For some resources where it makes sense). I would like to be able to use this mapping when encoding/decoding JSON representations on the fly. There doesn't seem to be a good way to do this. What I'm really trying to avoid is having the API clients dealing with references to objects that are basically (type, id) tuple, that doesn't seem restful. Thanks for any additional insight. -- View this message in context: http://restlet-discuss.1400322.n2.nabble.com/Bi-directional-Object-ID-to-URL-mapping-tp6990139p6990139.html Sent from the Restlet Discuss mailing list archive at Nabble.com. ------------------------------------------------------ http://restlet.tigris.org/ds/viewMessage.do?dsForumId=4447&dsMessageId=2877766

