@@ -1773,67 +1773,69 @@ F.web = F.route = function(url, funcExecute, flags, length, language) {
17731773 if ( subdomain )
17741774 F . _length_subdomain_web ++ ;
17751775
1776- F . routes . web . push ( {
1777- hash : hash ,
1778- id : id ,
1779- name : name ,
1780- priority : priority ,
1781- sitemap : sitemap ? sitemap . id : '' ,
1782- schema : schema ,
1783- workflow : workflow ,
1784- subdomain : subdomain ,
1785- description : description ,
1786- controller : _controller ? _controller : 'unknown' ,
1787- owner : _owner ,
1788- urlraw : urlraw ,
1789- url : routeURL ,
1790- param : arr ,
1791- flags : flags || EMPTYARRAY ,
1792- flags2 : flags_to_object ( flags ) ,
1793- method : method ,
1794- execute : funcExecute ,
1795- length : ( length || F . config [ 'default-request-length' ] ) * 1024 ,
1796- middleware : middleware ,
1797- timeout : timeout === undefined ? ( isDELAY ? 0 : F . config [ 'default-request-timeout' ] ) : timeout ,
1798- isGET : flags . indexOf ( 'get' ) !== - 1 ,
1799- isMULTIPLE : isMULTIPLE ,
1800- isJSON : isJSON ,
1801- isXML : flags . indexOf ( 'xml' ) !== - 1 ,
1802- isRAW : isRaw ,
1803- isBINARY : isBINARY ,
1804- isMOBILE : isMOBILE ,
1805- isROBOT : isROBOT ,
1806- isMOBILE_VARY : isMOBILE ,
1807- isGENERATOR : isGENERATOR ,
1808- MEMBER : membertype ,
1809- isASTERIX : isASTERIX ,
1810- isROLE : isROLE ,
1811- isREFERER : flags . indexOf ( 'referer' ) !== - 1 ,
1812- isHTTPS : flags . indexOf ( 'https' ) !== - 1 ,
1813- isHTTP : flags . indexOf ( 'http' ) !== - 1 ,
1814- isDEBUG : flags . indexOf ( 'debug' ) !== - 1 ,
1815- isRELEASE : flags . indexOf ( 'release' ) !== - 1 ,
1816- isPROXY : flags . indexOf ( 'proxy' ) !== - 1 ,
1817- isBOTH : isNOXHR ? false : true ,
1818- isXHR : flags . indexOf ( 'xhr' ) !== - 1 ,
1819- isUPLOAD : flags . indexOf ( 'upload' ) !== - 1 ,
1820- isSYSTEM : url . startsWith ( '/#' ) ,
1821- isCACHE : ! url . startsWith ( '/#' ) && ! CUSTOM && ! arr . length && ! isASTERIX ,
1822- isPARAM : arr . length > 0 ,
1823- isDELAY : isDELAY ,
1824- CUSTOM : CUSTOM ,
1825- options : options ,
1826- regexp : reg ,
1827- regexpIndexer : regIndex
1828- } ) ;
1829-
1830- F . emit ( 'route' , 'web' , F . routes . web [ F . routes . web . length - 1 ] ) ;
1776+ var instance = new FrameworkRoute ( ) ;
1777+ var r = instance . route ;
1778+ r . hash = hash ;
1779+ r . id = id ;
1780+ r . name = name ;
1781+ r . priority = priority ;
1782+ r . sitemap = sitemap ? sitemap . id : '' ;
1783+ r . schema = schema ;
1784+ r . workflow = workflow ;
1785+ r . subdomain = subdomain ;
1786+ r . description = description ;
1787+ r . controller = _controller ? _controller : 'unknown' ;
1788+ r . owner = _owner ;
1789+ r . urlraw = urlraw ;
1790+ r . url = routeURL ;
1791+ r . param = arr ;
1792+ r . flags = flags || EMPTYARRAY ;
1793+ r . flags2 = flags_to_object ( flags ) ;
1794+ r . method = method ;
1795+ r . execute = funcExecute ;
1796+ r . length = ( length || F . config [ 'default-request-length' ] ) * 1024 ;
1797+ r . middleware = middleware ;
1798+ r . timeout = timeout === undefined ? ( isDELAY ? 0 : F . config [ 'default-request-timeout' ] ) : timeout ;
1799+ r . isGET = flags . indexOf ( 'get' ) !== - 1 ;
1800+ r . isMULTIPLE = isMULTIPLE ;
1801+ r . isJSON = isJSON ;
1802+ r . isXML = flags . indexOf ( 'xml' ) !== - 1 ;
1803+ r . isRAW = isRaw ;
1804+ r . isBINARY = isBINARY ;
1805+ r . isMOBILE = isMOBILE ;
1806+ r . isROBOT = isROBOT ;
1807+ r . isMOBILE_VARY = isMOBILE ;
1808+ r . isGENERATOR = isGENERATOR ;
1809+ r . MEMBER = membertype ;
1810+ r . isASTERIX = isASTERIX ;
1811+ r . isROLE = isROLE ;
1812+ r . isREFERER = flags . indexOf ( 'referer' ) !== - 1 ;
1813+ r . isHTTPS = flags . indexOf ( 'https' ) !== - 1 ;
1814+ r . isHTTP = flags . indexOf ( 'http' ) !== - 1 ;
1815+ r . isDEBUG = flags . indexOf ( 'debug' ) !== - 1 ;
1816+ r . isRELEASE = flags . indexOf ( 'release' ) !== - 1 ;
1817+ r . isPROXY = flags . indexOf ( 'proxy' ) !== - 1 ;
1818+ r . isBOTH = isNOXHR ? false : true ;
1819+ r . isXHR = flags . indexOf ( 'xhr' ) !== - 1 ;
1820+ r . isUPLOAD = flags . indexOf ( 'upload' ) !== - 1 ;
1821+ r . isSYSTEM = url . startsWith ( '/#' ) ;
1822+ r . isCACHE = ! url . startsWith ( '/#' ) && ! CUSTOM && ! arr . length && ! isASTERIX ;
1823+ r . isPARAM = arr . length > 0 ;
1824+ r . isDELAY = isDELAY ;
1825+ r . CUSTOM = CUSTOM ;
1826+ r . options = options ;
1827+ r . regexp = reg ;
1828+ r . regexpIndexer = regIndex ;
1829+ r . type = 'web' ;
1830+
1831+ F . routes . web . push ( r ) ;
1832+ F . emit ( 'route' , 'web' , instance ) ;
18311833
18321834 // Appends cors route
18331835 isCORS && F . cors ( urlcache , corsflags ) ;
18341836 ! _controller && F . $routesSort ( 1 ) ;
18351837
1836- return F ;
1838+ return instance ;
18371839} ;
18381840
18391841function flags_to_object ( flags ) {
@@ -2379,43 +2381,44 @@ F.websocket = function(url, funcInitialize, flags, length) {
23792381 if ( subdomain )
23802382 F . _length_subdomain_websocket ++ ;
23812383
2382- F . routes . websockets . push ( {
2383- id : id ,
2384- urlraw : urlraw ,
2385- hash : hash ,
2386- controller : _controller ? _controller : 'unknown' ,
2387- owner : _owner ,
2388- url : routeURL ,
2389- param : arr ,
2390- subdomain : subdomain ,
2391- priority : priority ,
2392- flags : flags || EMPTYARRAY ,
2393- flags2 : flags_to_object ( flags ) ,
2394- onInitialize : funcInitialize ,
2395- protocols : protocols || EMPTYARRAY ,
2396- allow : allow || [ ] ,
2397- length : ( length || F . config [ 'default-websocket-request-length' ] ) * 1024 ,
2398- isWEBSOCKET : true ,
2399- MEMBER : membertype ,
2400- isJSON : isJSON ,
2401- isBINARY : isBINARY ,
2402- isROLE : isROLE ,
2403- isASTERIX : isASTERIX ,
2404- isHTTPS : flags . indexOf ( 'https' ) ,
2405- isHTTP : flags . indexOf ( 'http' ) ,
2406- isDEBUG : flags . indexOf ( 'debug' ) ,
2407- isRELEASE : flags . indexOf ( 'release' ) ,
2408- CUSTOM : CUSTOM ,
2409- middleware : middleware ? middleware : null ,
2410- options : options ,
2411- isPARAM : arr . length > 0 ,
2412- regexp : reg ,
2413- regexpIndexer : regIndex
2414- } ) ;
2415-
2416- F . emit ( 'route' , 'websocket' , F . routes . websockets [ F . routes . websockets . length - 1 ] ) ;
2384+ var instance = new FrameworkRoute ( ) ;
2385+ var r = instance . route ;
2386+ r . id = id ;
2387+ r . urlraw = urlraw ;
2388+ r . hash = hash ;
2389+ r . controller = _controller ? _controller : 'unknown' ;
2390+ r . owner = _owner ;
2391+ r . url = routeURL ;
2392+ r . param = arr ;
2393+ r . subdomain = subdomain ;
2394+ r . priority = priority ;
2395+ r . flags = flags || EMPTYARRAY ;
2396+ r . flags2 = flags_to_object ( flags ) ;
2397+ r . onInitialize = funcInitialize ;
2398+ r . protocols = protocols || EMPTYARRAY ;
2399+ r . allow = allow || [ ] ;
2400+ r . length = ( length || F . config [ 'default-websocket-request-length' ] ) * 1024 ;
2401+ r . isWEBSOCKET = true ;
2402+ r . MEMBER = membertype ;
2403+ r . isJSON = isJSON ;
2404+ r . isBINARY = isBINARY ;
2405+ r . isROLE = isROLE ;
2406+ r . isASTERIX = isASTERIX ;
2407+ r . isHTTPS = flags . indexOf ( 'https' ) ;
2408+ r . isHTTP = flags . indexOf ( 'http' ) ;
2409+ r . isDEBUG = flags . indexOf ( 'debug' ) ;
2410+ r . isRELEASE = flags . indexOf ( 'release' ) ;
2411+ r . CUSTOM = CUSTOM ;
2412+ r . middleware = middleware ? middleware : null ;
2413+ r . options = options ;
2414+ r . isPARAM = arr . length > 0 ;
2415+ r . regexp = reg ;
2416+ r . regexpIndexer = regIndex ;
2417+ r . type = 'websocket' ;
2418+ F . routes . websockets . push ( r ) ;
2419+ F . emit ( 'route' , 'websocket' , r ) ;
24172420 ! _controller && F . $routesSort ( 2 ) ;
2418- return F ;
2421+ return instance ;
24192422} ;
24202423
24212424/**
@@ -2519,24 +2522,25 @@ F.file = function(fnValidation, fnExecute, flags) {
25192522 } else if ( ! extensions && ! fnValidation )
25202523 fnValidation = fnExecute ;
25212524
2522-
2523- F . routes . files . push ( {
2524- id : id ,
2525- urlraw : urlraw ,
2526- controller : _controller ? _controller : 'unknown' ,
2527- owner : _owner ,
2528- url : url ,
2529- fixedfile : fixedfile ,
2530- wildcard : wildcard ,
2531- extensions : extensions ,
2532- onValidate : fnValidation ,
2533- execute : fnExecute ,
2534- middleware : middleware ,
2535- options : options
2536- } ) ;
2537-
2525+ var instance = new FrameworkRoute ( ) ;
2526+ var r = instance . route ;
2527+ r . id = id ;
2528+ r . urlraw = urlraw ;
2529+ r . controller = _controller ? _controller : 'unknown' ;
2530+ r . owner = _owner ;
2531+ r . url = url ;
2532+ r . fixedfile = fixedfile ;
2533+ r . wildcard = wildcard ;
2534+ r . extensions = extensions ;
2535+ r . onValidate = fnValidation ;
2536+ r . execute = fnExecute ;
2537+ r . middleware = middleware ;
2538+ r . options = options ;
2539+ r . type = 'file' ;
2540+
2541+ F . routes . files . push ( r ) ;
25382542 F . routes . files . sort ( ( a , b ) => ! a . url ? - 1 : ! b . url ? 1 : a . url . length > b . url . length ? - 1 : 1 ) ;
2539- F . emit ( 'route' , 'file' , F . routes . files [ F . routes . files . length - 1 ] ) ;
2543+ F . emit ( 'route' , 'file' , r ) ;
25402544 F . _length_files ++ ;
25412545 return F ;
25422546} ;
@@ -9266,11 +9270,80 @@ F.wait = function(name, enable) {
92669270 return enable === true ;
92679271} ;
92689272
9269- // *********************************************************************************
9273+ // =================================================================================
9274+ // Framework route
9275+ // =================================================================================
9276+
9277+ function FrameworkRoute ( ) {
9278+ this . route = { } ;
9279+ }
9280+
9281+ FrameworkRoute . prototype = {
9282+ get id ( ) {
9283+ return this . route . id ;
9284+ } ,
9285+ set id ( value ) {
9286+ this . route . id = value ;
9287+ } ,
9288+ get description ( ) {
9289+ return this . route . description ;
9290+ } ,
9291+ set description ( value ) {
9292+ this . route . description = value ;
9293+ } ,
9294+ get maxlength ( ) {
9295+ return this . route . length ;
9296+ } ,
9297+ set maxlength ( value ) {
9298+ this . route . length = value ;
9299+ } ,
9300+ get options ( ) {
9301+ return this . route . options ;
9302+ } ,
9303+ set options ( value ) {
9304+ this . route . options = value ;
9305+ } ,
9306+ get url ( ) {
9307+ return this . route . urlraw ;
9308+ } ,
9309+ get flags ( ) {
9310+ return this . route . flags || EMPTYARRAY ;
9311+ }
9312+ } ;
9313+
9314+ FrameworkRoute . prototype . make = function ( fn ) {
9315+ fn && fn . call ( this , this ) ;
9316+ return this ;
9317+ } ;
9318+
9319+ FrameworkRoute . prototype . setId = function ( value ) {
9320+ this . route . id = value ;
9321+ return this ;
9322+ } ;
9323+
9324+ FrameworkRoute . prototype . setDecription = function ( value ) {
9325+ this . route . description = value ;
9326+ return this ;
9327+ } ;
9328+
9329+ FrameworkRoute . prototype . setTimeout = function ( value ) {
9330+ this . route . timeout = value ;
9331+ return this ;
9332+ } ;
9333+
9334+ FrameworkRoute . prototype . setMaxLength = function ( value ) {
9335+ this . route . length = value ;
9336+ return this ;
9337+ } ;
9338+
9339+ FrameworkRoute . prototype . setOptions = function ( value ) {
9340+ this . route . options = value ;
9341+ return this ;
9342+ } ;
9343+
92709344// =================================================================================
92719345// Framework path
92729346// =================================================================================
9273- // *********************************************************************************
92749347
92759348function FrameworkPath ( ) { }
92769349
@@ -9403,11 +9476,9 @@ FrameworkPath.prototype.package = function(name, filename) {
94039476 return F . isWindows ? p . replace ( REG_WINDOWSPATH , '/' ) : p ;
94049477} ;
94059478
9406- // *********************************************************************************
94079479// =================================================================================
94089480// Cache declaration
94099481// =================================================================================
9410- // *********************************************************************************
94119482
94129483function FrameworkCache ( ) {
94139484 this . items = { } ;
0 commit comments