我正在使用 Node 和 express 。要注册我调用的 Controller :
app.get('/user/:id', function (req, res) {...});
但我想这样做 rfc-6570方式:
app.get('/user/{id}', function (req, res) {...});
我在谷歌代码上搜索了一个 python 实现,但没有找到任何 JavaScript 代码(除了谷歌代码到 http://www.snellspace.com/wp/?p=831 的死链接)。
一般来说,URI 模板并不像第一眼看上去那么容易。查看 RFC 中的示例。
PS:我也需要客户端上的 URI 模板。
最佳答案
我一直在清理 http://code.google.com/p/uri-templates/wiki/Implementations 的实现列表- https://github.com/marc-portier/uri-templates 有一个 JS但我不确定它是否实现了 RFC,也不知道它的质量如何。
请注意,我们已经开始在这里发布测试: https://github.com/uri-templates/uritemplate-test
所以如果你想检查它,你可以从那里开始。
关于javascript - URI 模板 : Is there an rfc-6570 implementation in javascript?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10464152/