Hi Michael,

Michael Marth schrieb:
> Hi Felix,
> 
> I have a question about that:
> 
> URL for the selection of the concrete representation (script). For other
>> requests (POST, DELETE, ...) you want to modify the resource (and don't
>> care for the representation) and hence _should_ address the resource
>> directly without any representational detail such as selectors and
>> extensions."
>>
> 
> I would like to implement two different POST features on one node. As
> always, a blog example :) The nodes are blog posts, one feature is posting
> reader comments, the second feature is trackbacks (which come along as POST
> requests from other blogs).
> 
> For the comments I am OK with the default behavior (I do not want to
> overwrite POST.esp). For the trackback feature I need to implement a custom
> behavior (as specified or rather agreed upon by the different blog systems).
> How could I construct a URL that would make it possible to distinguish the
> two POSTs if there are no selectors?

You can help yourself with a servlet which you write for your blog post
resource type handling POST requests.

In addition your servlet would implement the OptingServlet interface,
which has the accepts(SlingHttpServletRequest) method. In this method
you check whether the POST request is a Trackback request or not. If the
request is a simple update POST, just return false and your servlet will
be ignored.

If the POST request is a Trackback request, return true and your servlet
will be called to handle the POST request and the default
SlingPostServlet will not be called.

> 
> Related to this: trackback POSTs are supposed to return an xml document
> containing success or error messages. So in my understanding of Sling's
> handling of extensions for GET requests the URL for trackback POSTs should
> end in .xml. You might say that there is no problem, because Sling ignores
> the extension anyway, so it might as well be .xml, but it seems a bit
> inconsistent to me. I think a POST to /foo.xml should return xml and a POST
> to /foo.html should return html

Agreed. There is an issue actually deailing with this problem.

There is of course a subtle point: the SlingPostServlet actually returns
an XHTML response, though marked as text/html (which only half-way, what
you want). Nevertheless it is correct XML.


Hope this helps.

Regards
Felix


Reply via email to