Hi, This is the source.
var uri = request.getRequestURI(); var callPath=uri.replace("/store",""); var action = "list"; // default action list the topics if(uri != null) { var uriMatcher = new URIMatcher(callPath); if (uriMatcher.match("/forum") || uriMatcher.match("/forum/")) { action = "list"; } else if (uriMatcher.match("/forum/new")) { action = "new"; // create topic } else if (uriMatcher.match("/forum/new/{id}")) { action = "new"; // create topic } else if (uriMatcher.match("/forum/topic/{id}")) { var topic = uriMatcher.elements().id; action = "topic"; } else { action = "exit"; } } if(action == "exit"){ *response.sendError(404);* } else { // Logic comes here } 404 will refer to <APIM_HOME>/repository/deployment/server/jaggeryapps/store/pages/error-pages/404.html Thanks. On Tue, Oct 20, 2015 at 10:39 AM, Sajith Ariyarathna <sajit...@wso2.com> wrote: > Hi Thilini, > > Can you share your code here? > > I tested following Jaggery code. (Test was executed in* AppM 1.0.0* pack > and *Advanced Rest Client* was used as the HTTP client) > > *URL Mapping in jaggery.conf: * > > { > > "url": "/test/*", > > "path": "/lib/test.jag" > > } > > > *File*: *test.jag* > > *Code:* > > var log = new Log("[testing]"); > > log.info("Hit for HTTP method " + request.getMethod()); > > response.sendError(404, "Testing page not found."); > > > *Terminal Output:* > > [2015-10-20 10:26:52,885] INFO - [testing] Hit for HTTP method GET > > [2015-10-20 10:26:57,499] INFO - [testing] Hit for HTTP method POST > > [2015-10-20 10:27:02,045] INFO - [testing] Hit for HTTP method PUT > > [2015-10-20 10:27:06,011] INFO - [testing] Hit for HTTP method DELETE > > [2015-10-20 10:27:08,491] INFO - [testing] Hit for HTTP method HEAD > > [2015-10-20 10:27:10,860] INFO - [testing] Hit for HTTP method OPTIONS > > > *HTTP Output:* > > 404 Not Found > > 404 Not Found > > 404 Not Found > > 404 Not Found > > 404 Not Found > > 404 Not Found > > > Since the expected output was received in above, I believe the issue is on > your side, not in Jaggery. > > Thanks. > > On Mon, Oct 19, 2015 at 2:04 PM, Thilini Cooray <thili...@wso2.com> wrote: > >> Hi, >> >> I want to send error messages for invalid URLs from API Manager Store >> jaggery layer. >> >> I use response.sendError(404) for this purpose. >> For HTTP POST and GET this method returns the correct error page while it >> doesn't return any message for PUT and DELETE. >> >> I debugged [1] and found out that the errors send in all HTTP methods >> gets hit in >> >> rho.response.sendError((Integer) args[0]); >> >> Output stream of rho.response also contains the correct error page in all >> HTTP methods. >> Yet it doesn't get returned in HTTP PUT and DELETE methods. >> >> I am unable to figure out the reason for this behaviour. >> Any help is appreciated. >> >> Thanks. >> >> [1] >> http://svn.wso2.org/repos/wso2/carbon/platform/tags/turing-chunk04/components/jaggery/0.9.0.ALPHA4.wso2v1/hostobjects/org.jaggeryjs.hostobjects.web/src/main/java/org/jaggeryjs/hostobjects/web/ResponseHostObject.java >> >> -- >> Best Regards, >> >> *Thilini Cooray* >> Software Engineer >> Mobile : +94 (0) 774 570 112 <%2B94%20%280%29%20773%20451194> >> E-mail : thili...@wso2.com >> >> WSO2 Inc. www.wso2.com >> lean.enterprise.middleware >> >> _______________________________________________ >> Dev mailing list >> Dev@wso2.org >> http://wso2.org/cgi-bin/mailman/listinfo/dev >> >> > > > -- > Sajith Ariyarathna > Software Engineer; WSO2, Inc.; http://wso2.com/ > mobile: +94 77 6602284, +94 71 3951048 > -- Best Regards, *Thilini Cooray* Software Engineer Mobile : +94 (0) 774 570 112 <%2B94%20%280%29%20773%20451194> E-mail : thili...@wso2.com WSO2 Inc. www.wso2.com lean.enterprise.middleware
_______________________________________________ Dev mailing list Dev@wso2.org http://wso2.org/cgi-bin/mailman/listinfo/dev