Hi everyone,
I am working on a generic store for JSON using a RESTful API.
Basically you can PUT any JSON to our store and it will be sliced up so you can retrive it entirely or only slices of.
Now we one of our clients wondered if we could offer bachted READs on different section of this resource hierarchy.
Here is an example:
PUT /mydata
{
"user" : {
"name" : "John",
"surname" : "Doe",
"age" : 22
},
"permissions" : [READ,WRITE, DELETE],
"session" : {
"cookie" : "asdasdjas",
"history" {
"somekey" : "somevalue",
"somekey2" : "somevalue",
}
}
When the user does a GET on /mydata he will receive exactly the JSON as above.
If he does a GET on /mydata/session/history he will receive
{
"somekey" : "somevalue",
"somekey2" : "somevalue",
}
Now he knows he has to get the 'user' object and the '/sessions/history' object from the same 'mydata' object.
I was wondering what were good patterns to allow this?
The only clean idea had was to use matrix params for filtering, as in GET /mydata;filter=user;filter=sessions/history
This would return
{
"user" : {
"name" : "John",
"surname" : "Doe",
"age" : 22
},
"history" {
"somekey" : "somevalue",
"somekey2" : "somevalue",
}
}
What do you think? How would you approach such a task?
Cheers,
Felipe