Very simple question. I want to provide a URI for some objects in my application. For example, a resource is available at:
http://localhost:8080/myapp/user/1
However, I would like to serialize such a User object. This serialization must contain the public URI of the object itself. So, for example, the model has a new method serializeToSomethingthat will be serialized:
id: 1
username: JohnDoe
email: johndoe@example.com
publicURI: http://localhost:8080/myapp/user/1
How can I let a model instance know its URL?
Some notes:This should happen within the model, controller, or service, and not in the view. Also I do not want to do this.
slhck source
share