I have made the change for this but unfortunately it's not directly linked
to git. Below is the code of the route action wrapper -
*Route Action wrapper*
/*
A wrapper object that wraps request, response, session and few utility
methods
*/
var RouteAction = function(request, response, session, params){
var route_action = {};
route_action._req = request;
route_action._res = response;
route_action._session = session;
route_action._params = params;
route_action._query = function(){
return request.getAllParameters();
};
route_action._body = function(){
var content=request.getContent();
var contentObj={};
//Only parse if the user has provided any content
if(content){
contentObj=parse(content);
}
return contentObj;
};
route_action._headers = function(){
return request.getAllHeaders();
};
route_action._files = function(){
var files = request.getAllFiles();
var files_array = [];
for(var name in files) {
if(files.hasOwnProperty(name)) {
files_array.push({
name : name,
file : files[name]
});
}
}
return files_array;
}
return route_action;
}
*Implementation to the route.js*
var route_action = new RouteAction(req,res,session, match.params);
return match.ref(route_action)||{};
Cheers~
On Mon, Mar 3, 2014 at 11:37 AM, Chan <[email protected]> wrote:
> Thanks Sameera. Other than that I started working on the jaggery-router to
> improve it in the below method
>
> - Change public signature of a route as router.get($route,
> function($ctx){});
> - $ctx will have _request, _response, _session, _headers(), _params,
> _body(), _files()
>
> We'll review these changes and merge them to the main router.
> Cheers~
>
>
> On Mon, Mar 3, 2014 at 1:12 AM, Sameera Medagammaddegedara <
> [email protected]> wrote:
>
>> Hello Chan,
>>
>> Can try you changing the following line ;
>>
>> router.get('resource',function .......
>>
>>
>> to:
>>
>> router.get('/resource',function ....
>>
>>
>> Please let me know if this fixes your problem.
>>
>> Thank You,
>> Sameera
>>
>>
>> On Sun, Mar 2, 2014 at 11:39 PM, Chan <[email protected]> wrote:
>>
>>> Hi Sameera,
>>> I am faced in an issue where my route is not being accessed. My code is
>>> at on github [1]. I think the route is being added to the route tree but
>>> it's not being executed.
>>>
>>> Also it would be better make the public api of a route function in the
>>> below construct.
>>>
>>> function(context){
>>>
>>> context._request // for request object
>>>
>>> context._response // for response object
>>>
>>> context._session // for session object
>>> context._param // for params hash
>>> context._body // for body
>>>
>>> context._files // for files coming in the request
>>>
>>> }
>>>
>>> [1] - https://github.com/dulichan/storage
>>>
>>> --
>>> Chan (Dulitha Wijewantha)
>>> Software Engineer - Mobile Development
>>> WSO2Mobile
>>> Lean.Enterprise.Mobileware
>>> * ~Email [email protected] <[email protected]>*
>>> * ~Mobile +94712112165 <%2B94712112165>*
>>>
>>> * ~Website dulithawijewantha.com <http://dulithawijewantha.com/> *
>>>
>>> * ~Blog blog.dulithawijewantha.com
>>> <http://dulichan.github.io/chan/>*
>>> * ~Twitter @dulitharw <https://twitter.com/dulitharw>*
>>>
>>
>>
>>
>> --
>> Sameera Medagammaddegedara
>> Software Engineer
>>
>> Contact:
>> Email: [email protected]
>> Mobile: + 94 077 255 3005
>>
>
>
>
> --
> Chan (Dulitha Wijewantha)
> Software Engineer - Mobile Development
> WSO2Mobile
> Lean.Enterprise.Mobileware
> * ~Email [email protected] <[email protected]>*
> * ~Mobile +94712112165 <%2B94712112165>*
> * ~Website dulitha.me <http://dulitha.me>*
> * ~Twitter @dulitharw <https://twitter.com/dulitharw>*
> *~SO @chan <http://stackoverflow.com/users/813471/chan>*
>
--
Chan (Dulitha Wijewantha)
Software Engineer - Mobile Development
WSO2Mobile
Lean.Enterprise.Mobileware
* ~Email [email protected] <[email protected]>*
* ~Mobile +94712112165*
* ~Website dulitha.me <http://dulitha.me>*
* ~Twitter @dulitharw <https://twitter.com/dulitharw>*
*~SO @chan <http://stackoverflow.com/users/813471/chan>*
_______________________________________________
Dev mailing list
[email protected]
http://wso2.org/cgi-bin/mailman/listinfo/dev