javascript - URI 模板 : Is there an rfc-6570 implementation in javascript?

标签 javascript node.js express uritemplate

我正在使用 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/

相关文章:

javascript - 使用 Google Apps 脚本调整评估之间日期的文件创建日期值

javascript - 如何使用原生 JavaScript 实现无限滚动?

node.js - 如何防止模块在 NodeJS 的生产中加载?

javascript - Sails.js - 扩展 req 原型(prototype)

node.js - 从 Jade 中的子模板设置页面标题

javascript - Promise 函数需要使用 return 吗?

javascript - 将总计从选择菜单选项获取到另一个表格单元格

node.js - 使用云功能将多个文件保存到 Firebase 存储

node.js - 如果数组中不存在新记录,则尝试添加新记录

node.js - 在 MEANJS 的 CRUD 中的 URL 中使用 slugs