On 4/27/2018 11:45 AM, DevaGerald wrote:
> Hi,
> 
> Sorry if i miss something here. As of my knowledge, the struts 2 rest plugin
> supports only the following :
> /resource - GET 
> /resource - POST
> /resource/$resource_id - GET
> /resource/$resource_id - PUT
> /resource/$resource_id - DELETE
> 
> and also the custom methods like
> /resource/$resource_id/my_custom_method - This will land me to the
> respective custom method.
> 
> I need to write the following API pattern.
> 
> /resource/$resource_id/sub_resource/$sub_resource_id
> 
> Is this be supported? Plz help me with this.
> 

As far as I see at [1], only the last slash location makes sense, so, it
seems no, this isn't supported.

However, in Struts REST plugin it seems resources are actions e.g.
"DELETE /resource/$resource_id" calls method "setId" of the action
"resource" with value "$resource_id" and then calls method "destroy".
It's up to you what do you write inside "destroy" method.

So, according to above paragraph, could you please describe what are you
trying to achieve with e.g. "DELETE
/resource/$resource_id/sub_resource/$sub_resource_id"? Because in Struts
REST plugin, "resource" and "sub_resource" will be evaluated as two
actions, not two master/child database records.

Regards.


[1]
https://github.com/apache/struts/blob/5ebd716fb7ffe10c6f1857c993285c63ab57f838/plugins/rest/src/main/java/org/apache/struts2/rest/RestActionMapper.java#L340

Reply via email to