zf-fr / zfr-rest

A module for Zend Framework 2 that aims to simplify RESTful
81 stars 31 forks source link

Allow for metadata in response #170

Closed macnibblet closed 9 years ago

macnibblet commented 10 years ago

Allows for returning metadata in the response.

class ExampleObject
{
   protected $name = 'el awesome';

   protected $coordinate = '11,11';
}
GET /example-objects?coordinate=10,10&distance=100 HTTP/1.1
{
   "data": [
        { "0": {
             "name": "el awesome",
             "coordinate": "11,11"
          },
          "distance": 1337
       }
   ]
}
bakura10 commented 10 years ago

What is the use case of that? :)

macnibblet commented 10 years ago

So it's pretty much the same structure as when you do stuff with doctrine.

Ocramius commented 10 years ago

@macnibblet I do not understand the returned example response in this issue

macnibblet commented 10 years ago

For example when you query for a collection of locations that are within the given radius/target of a distance you might also want to know the distance to the target.

So you would have a response that returns the object in [0] and the metadata named after it's name exactly how doctrine handles when you add COUNT or some other statement

Ocramius commented 10 years ago

@macnibblet you are talking about aggregating more data in the results then. I don't think it's a good idea, since you are modifying the resource (which is /example-objects)

bakura10 commented 9 years ago

I'm closing, #184 will bring a whole new architecture that is not backward-compatible.