Skip to content

Commit

Permalink
New format for defining server middleware in Service.use.
Browse files Browse the repository at this point in the history
  • Loading branch information
lsm committed Aug 26, 2015
1 parent d448773 commit f904483
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 11 deletions.
4 changes: 2 additions & 2 deletions example/account/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ var Account = module.exports = Service.extend({
},

use: {
// tell micromono to use `partial-render` middleware at the server side
// tell micromono to use `layout` middleware at the server side
// for request url matching `/account/:page`.
'/:page': 'partial-render'
'layout': '/:page'
},

/**
Expand Down
6 changes: 3 additions & 3 deletions example/home/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ var Home = module.exports = Service.extend({
baseUrl: '/',

use: {
// tell micromono to use `partial-render` middleware at the server side
// for request url matching `/account/:page?`.
'/:page?': 'partial-render'
// tell micromono to use `layout` middleware at the server side
// for request urls in the array.
'layout': ['/private', '/public', '/$']
},

route: {
Expand Down
4 changes: 2 additions & 2 deletions example/io/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,9 +9,9 @@ var IO = module.exports = Service.extend({
baseUrl: '/io',

use: {
// tell micromono to use `partial-render` middleware at the server side
// tell micromono to use `layout` middleware at the server side
// for request url matching `/io/$`.
'/$': 'partial-render'
'layout': '/$'
},

route: {
Expand Down
8 changes: 4 additions & 4 deletions lib/micromono.js
Original file line number Diff line number Diff line change
Expand Up @@ -243,10 +243,10 @@ function runService(micromono, app, ServiceFactory, callback) {
}

if (ann.use && app) {
Object.keys(ann.use).forEach(function(key) {
var name = ann.use[key];
var middleware = require('./middleware/' + name);
serviceInstance.app.use(key, middleware(app));
Object.keys(ann.use).forEach(function(middlewareName) {
var url = ann.use[middlewareName];
var middleware = require('./middleware/' + middlewareName);
serviceInstance.app.use(url, middleware(app));
});
}

Expand Down

0 comments on commit f904483

Please sign in to comment.