【发布时间】:2015-01-27 03:42:34
【问题描述】:
我尝试像这样使用 Restify 的“use()”方法:
...
server = Restify.createServer(@options)
server.use(Restify.queryParser())
server.use(Restify.urlEncodedBodyParser())
server.use(Restify.CORS())
server.use( (req, res, next) ->
console.log('TEST')
next()
)
server.listen() ... etc.
但是“测试”永远不会发生:(
@options 是我的局部变量:
@options.name = 'test-server'
@options.version = '0.0.1'
@options.host ?= @options.host || '0.0.0.0'
@options.listenPort ?= @options.port || process.env.PORT || 5000
@options.accept = [
'text/html',
]
@formatter = new Formatter(@options)
@options.formatters = {
# supported output
'text/html': @formatter.html,
# unsupported output
'*/*': @formatter.error
}
【问题讨论】:
-
@options
-
我添加了@options 信息...
-
那不是一个有效的格式,你知道任何 javascript 吗?
-
什么无效?这是咖啡脚本...
-
你应该用 coffescript 标签标记问题然后
标签: node.js coffeescript restify