[FLOW3-general] Trying to REST ;)
Oliver Wand
wand at itaw.de
Sun Nov 27 10:47:43 CET 2011
Hi Bastian,
thanks again for providing your example.
This is working good except for one important issue:
When trying to access a product which isn't here the REST controller
does NOT return a 404 XML response.
Instead a FLOW3 404 exception is thrown, therefore the standard FLOW3
html exception is returned.
Obviously this doesn't make much sense in this case but I have no clue
how to get around this?
Any ideas would be highly appreciated :-)
Cheers,
Oliver
Am 27.10.11 13:04, schrieb Bastian Waidelich:
> Bastian Waidelich wrote:
>
> Hi Oliver,
>
>> I'll provide a little sample later. Now busy with the release ;)
>
> Ok, that was later later than I have planned..
> But in return I can provide you with a fully fledged REST example that
> supports XML, JSON and non-Ajax-Fallbacks:
> https://github.com/bwaidelich/REST-Test
>
> Most things, should be rather self-explanatory, but there are at least
> two things worth mentioning:
>
> 1. The current FLOW3 request handling does not support requests of type
> PUT. Besides the merging of GET and POST arguments is done in a way that
> does not play very well with REST because a matched route part can't be
> overridden. E.g. if you PUT to the URI
> "http://localhost/products/product-1" the argument $product is already
> mapped (usually to the UUID of the product) and won't be merged with
> your PUT data.
> I worked around this by providing a simple "RestRequestHandler" that is
> automatically used for POST, PUT & DELETE Web Requests that provide a
> Content-Type header (see
> https://github.com/bwaidelich/REST-Test/blob/master/Classes/RestRequestHandler.php#L51).
>
>
> 2. If you update a resource (PUT), you currently *have to* specify the
> __identity property. Otherwise the property mapper doesn't recognize the
> entity and the Repository::update() call will fail.
>
> A sample PUT request could look like this:
> <root>
> <product>
> <__identity>0b0a86a1-08aa-4d11-a21c-01b459fd3747</__identity>
> <name>Modified product name</name>
> <price>123.45</price>
> </product>
> </root>
>
> (set the *Accept* and *Content-Type* headers to "application/xml"!)
>
> The JSON version would look like:
> {
> "product":
> {
> "__identity": "c95af617-50eb-497a-aed7-08b9d8139c83",
> "name": "JSON Modified2",
> "price": "543.21"
> }
> }
> (*Accept* and *Content-Type* headers => "application/json"!)
>
>
> Let me know, if that works for you.
> Bastian
More information about the FLOW3-general
mailing list