Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with
or
.
Download ZIP
Browse files

なやましちゅう

  • Loading branch information...
commit db14d517d1261a180480e9cb275cd825e6d7341e 1 parent f9cfa3f
Kazuhiro Kotsutsumi authored
View
68 lib/ext-server/app/Router.js
@@ -15,6 +15,74 @@
*/
Ext.define('Ext.app.Router', {
+ // {{{ mixins
+
+ mixins: [
+ 'Ext.util.Observable'
+ ],
+
+ // }}}
+ // {{{ actionChain
+
+ actionChain: [],
+
+ // }}}
+ // {{{ dispatchTable
+
+ dispatchTable: {},
+
+ // }}}
+ // {{{ requestPath
+
+ requestPath: '/',
+
+ // }}}
+ // {{{ constructor
+
+ constructor: function(config) {
+
+ config = config || {};
+
+ Ext.apply(this, {
+ actionChain : [],
+ requestPath : '/',
+ dispatchTable : config.dispatchTable
+ });
+
+ },
+
+ // }}}
+ // {{{ buildChain
+
+ buildChain: function(requestPath) {
+
+ var me = this, chain = [];
+
+ Ext.iterate(me.dispatchTable, function(path, actions) {
+
+ var match = me.match(path, requestPath);
+
+ if(match) {
+ actions.forEach(function(action) {
+ chain.push(action);
+ });
+ }
+
+ });
+
+ return chain;
+ },
+
+ // }}}
+ // {{{ dispatch
+
+ dispatch: function() {
+
+ return this.buildChain();
+
+ },
+
+ // }}}
// {{{ match
match: function(path, url) {
View
40 lib/ext-server/server/Router.js
@@ -20,46 +20,18 @@ Ext.define('Ext.server.Router', {
extend: 'Ext.app.Router',
// }}}
- // {{{ dispatchTable
-
- dispatchTable: {},
-
- // }}}
- // {{{ constructor
-
- constructor: function(config) {
-
- config = config || {};
-
- Ext.apply(this, {
- dispatchTable: config.dispatchTable
- });
-
- },
-
- // }}}
// {{{ dispatch
dispatch: function(req, res, next) {
- var me = this;
-
- Ext.iterate(me.dispatchTable, function(path, actions) {
-
- var match = me.match(path, req.url);
-
- if(match) {
-
- actions.forEach(function(action) {
-
- // TODO:chain
-
- action(req, res, next);
-
- });
+ var chain;
- }
+ // call parent method.
+ chain = this.buildChain(req.url);
+ chain.push(next);
+ chain.shift()(req, res, function() {
+ chain.shift()(req, res, chain.shift());
});
}
View
41 test/shared/manual/controller/Index.js
@@ -1,41 +0,0 @@
-/* vim: set expandtab tabstop=4 shiftwidth=4 softtabstop=4: */
-
-// {{{ My.controller.Index
-
-Ext.define('My.controller.Index', {
-
- // {{{ extend
-
- extend: 'Ext.app.Controller',
-
- // }}}
- // {{{ init
-
- init: function() {
-
- this.control({
-
- '/index.html': function(req, res, next) {
-
- res.end('Hello World!');
-
- }
-
- });
-
- }
-
- // }}}
-
-});
-
-// }}}
-
-/*
- * Local variables:
- * tab-width: 4
- * c-basic-offset: 4
- * c-hanging-comment-ender-p: nil
- * End:
- */
-
View
3  test/shared/manual/server.js
@@ -8,8 +8,5 @@ Ext.application({
session: {
// type: 'redis'
},
- controllers: [
- 'Index'
- ]
});
Please sign in to comment.
Something went wrong with that request. Please try again.