RESTful API资源架构和语法;我做得对吗?
我正在努力在我的微框架中实现RESTful API资源架构。我正在利用我最近开发的奇特路由功能,与对象层次结构并行建模资源路径。 (哦,这很花哨!)
我正在使用的URI语法是:
'http:// www.site.com / resource [ ; key1 = param1 [ & key2 = param2 ] ]'
这将允许这样的URI:
'http://www.site.com/user;id=123/article;id=456'
映射到类似的东西(一旦我将此功能合并到路由器中):
$user->getByParams('id=123')->article->getByParams('id=456');
更进一步的例子:
'GET /user;id=123 GET'
# read User object data matching id=123
'GET /user;id=123/article;id=456'
# read Article object data matching id=456
# belonging to User object matching id=123
'GET /user;name=john&age=20/article;title=hello%20world'
# read Article object(s) data matching title='hello world'
# belonging to User object(s) matching name='john' and age=20
我遇到的问题是最后一个,将多个结果与查询数据匹配(SQL中的'laLIKE
)表示通配符的安全字符是什么? Asterisk(*
)出现在子分隔符保留列表http://lbs.apache.org/webarch/uri/rfc/rfc3986.html#reserved上,因此它将保持未编码状态。使用%25可能更容易(%
)
我理解这个问题可能是特定于实现的,但有没有任何现有的框架实现类似于此的RESTful API资源架构,我可以参考想法?
另外,我是否完全反对谷物?
没有找到相关结果
已邀请:
1 个回复
bab