     return if specialMethod is false
     #由业务逻辑指定的处理处理
     if specialMethod and biz[specialMethod]
-      console.log specialMethod, path
       #console.log(path, specialMethod)
-      app[method] path, ()->
-        biz[specialMethod].apply biz, Array.prototype.slice.call(arguments)
+      app[method] path, (req, res, next)->
+        #检查权限
+        requestPermission(method, router, req, res) && biz[specialMethod].call(biz, req, res, next)
       return
 
     #处理常规则的method
     app[method] path, (req, res, next)->
+      #用户校验
+      return if not requestPermission(method, router, req, res)
       #处理data部分
       data = {}
       switch method

###
_ = require 'underscore'
_config = require './config.json'


#获取crud的默认path
getPaths = (router)->
  paths = {}

  res.statusCode = 404
  res.end('404 Not Found')

#权限校验，仅检查用户是否已经登录，并不考虑用户的角色
requestPermission = (method, router, req, res)->
  return true
  #检查是否忽略权限检查
  return true if  _.indexOf(router.anonymity || [], method) >= 0

  #如果没有找到session中的member_id，则跳转401，并返回undefined
  return req.session.member_id || _common.response401(res)

module.exports = (app)->
  #首页
  app.get '/', (req, res, next)->
    res.sendfile 'static/index.html'


  _config.routers.forEach (router)->
    apiRouter app, router
