如何在不连接http服务器的情况下使用连接路由器?
我有一个功能:
function foo(request, response, next)
{
...
}
我想使用“connect”npm 库中的路由器来路由请求。但是,我只能在文档中找到如何将路由器附加到 connect 的内置 HTTP 服务器。我想做这样的事情:
var connect = require('connect')
function foo(request, response, next)
{
connect.middleware.router(request, response, next, function (app)
{
app.get('/', ...)
app.get('/openid/verify', ...)
...
})
}
问题是:如何传递请求、响应和下一步连接路由器?
I have a function:
function foo(request, response, next)
{
...
}
And I want to use the router from 'connect' npm library to route the request. However, I could only find in the documentation how to attach the router to the built-in HTTP server of connect. I want to do something like this:
var connect = require('connect')
function foo(request, response, next)
{
connect.middleware.router(request, response, next, function (app)
{
app.get('/', ...)
app.get('/openid/verify', ...)
...
})
}
The question is: how do I pass request, response and next to connect router?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
您应该能够执行以下操作:
You should be able to do the following: