[ 
https://issues.apache.org/struts/browse/WW-2515?page=com.atlassian.jira.plugin.system.issuetabpanels:comment-tabpanel&focusedCommentId=43416#action_43416
 ] 

Jeromy Evans commented on WW-2515:
----------------------------------

Last comment agreed.  That's why I suspect there should be a ResourceNotFound 
and MethodNotSupported exception that can be raised either by the 
RestActionMapper or Action.  A default exception handler could return 404 or 
405 respectively.  I think returning 404's is part of a larger solution rather 
than this patch.

For non-ModelDriven controllers, the action is serialized for the result and 
the action's properties define the model.  In this case a 404 may still be an 
appropriate response even though the target seen by the ContentTypeInterceptor 
is non-null.  I also still have a concern about responding with a 404 after the 
action has executed (I can see support about an action being invoked by a 
browser saying it couldn't find it).

I understand in RoR that "GET /path/user/1" returns a 404 if that id is invalid
What happens in RoR if '/path/user' does not exist as a controller?  is that a 
404 too?




> REST plugin does not throw a 404 if resource cannot be found
> ------------------------------------------------------------
>
>                 Key: WW-2515
>                 URL: https://issues.apache.org/struts/browse/WW-2515
>             Project: Struts 2
>          Issue Type: Bug
>          Components: Plugin - REST
>    Affects Versions: 2.1.1
>         Environment: Struts 2.1.1-SNAPSHOT using Jetty 6.1.5
>            Reporter: Sarat Pediredla
>         Attachments: WW-2515.patch
>
>
> When there is a GET request for a resource that does not exist, example GET 
> /authors/25 where author with id 25 does not exist, the getModel() method of 
> the action should return null (and in most cases will return null as the 
> object does not exist).
> However, the current ContentTypeInterceptor implementation is not entirely 
> RESTful as the right response should be HTTP Status Code 404 "Not Found".
> I have patched the ContentTypeInterceptor to return a 404 status if the 
> requested resource could not be found.

-- 
This message is automatically generated by JIRA.
-
You can reply to this email to add a comment to the issue online.

Reply via email to