In jaggery web request can be served by from .jag/.js (File). We have
noticed It is important to serve web request from the JS function rather
resource file such as (*.jag).



*Use case*



- User go to (send web request to) http://10.100.1.112:9763/testapp/

- Jaggery will check URL mapping that is define in jaggery.conf[2] in
'testapp' and get resource path (jaggery file) to server.

eg: Here is sample url mapping configuration in current jaggery.



*"urlMappings" : [*

*                          {*

*                                "url" : "/foo/*",*

*                                "path" : "foo/index.jag"*

*                          },*

*                          {*

*                                 "url" : "/bar/test/",*

*                                 "path" : "/private.jag"*

*                          }*

*                ],*




*Problem*


   - If jaggery application developer need to serve his/her user web
   request from function rather from file.
   - (With currently jaggery is not possible achieve this)



*Solution*


   - We will introduce new function for global scope of the application,
   such as called application.serve(Function function)
   - If application.serve defined in 'initScripts' for jaggery application
   all the request that coming to that application will be served by that
   function.
   - If application.serve is not defined in 'initScripts'. It will work as
   current way by looking on "urlMappings"
   - Therefore this change will not effect for existing jaggery
   application/application deployment also.
   - Routing logic (Can be used 3rd party) can be implemented in this
   function and this will be much user friendly for jaggery developers.



*[NOTE]*


   - Since this solution used application[1](Global scope). We will have to
   fixed thread safety[3] in jaggery for global scope.
   - This solution will help full for front end controller concept and
   improving REST service APIS in jaggery.

[1] http://jaggeryjs.org/apidocs/application.jag

[2] http://jaggeryjs.org/apidocs/jagconf.jag

[3]
http://madhukaudantha.blogspot.com/2014/02/introducing-sync-for-jaggery-javascript.html

-- 
*Madhuka* Udantha
Senior Software Engineer
Development Technologies
WSO2 Inc. : http://wso2.com

*Mobile*: +94774066336
*Blog*: http://madhukaudantha.blogspot.com/
_______________________________________________
Architecture mailing list
[email protected]
https://mail.wso2.org/cgi-bin/mailman/listinfo/architecture

Reply via email to