[关闭]
@bornkiller 2014-08-07T14:18:20.000000Z 字数 1182 阅读 2627

grunt-contrib-connect

javascript


grunt-contrib-connect

  1. base: [
  2. './',
  3. './libs/jquery',
  4. './libs/requirejs',
  5. './libs/requirejs-plugin',
  6. ]
  1. var middleware;
  2. if (options.middleware instanceof Array) {
  3. middleware = options.middleware;
  4. } else {
  5. middleware = createDefaultMiddleware.call(this, connect, options);
  6. if (typeof(options.middleware) === 'function') {
  7. middleware = options.middleware.call(this, connect, options, middleware);
  8. }
  9. }
  1. middleware: function(connect, options, middlewares) {
  2. middlewares.unshift(function(req, res, next) {
  3. var stubUrl = {
  4. "/user/info": {
  5. "name": "jason",
  6. "age": 23
  7. },
  8. "user/login": {
  9. "authority" : true
  10. }
  11. };
  12. if(!stubUrl.hasOwnProperty(req.url)) {
  13. return next();
  14. }
  15. res.end(JSON.stringify(stubUrl[req.url]));
  16. });
  17. return middlewares;
  18. }

requirejs-plugin

添加新批注
在作者公开此批注前,只有你和作者可见。
回复批注