0

我只是让自己进入前夜。伟大的框架,但我坚持使用 _links 到项目。

我有一个合同集合,只允许 item_methods。

domain.com/contracts/19687176add597c50b13b4188fcafd6d

每份合同可能有 n 个贷方票据,可通过以下方式访问:

domain.com/contracts/a78b1627f7858cc187bcad5d8abe19d3/creditnotes

-> 所有信用票据的列表。

列表中的每张贷方票据都有这样的链接:

_links": {
    "self": {
      "href": "domain.com/contracts/<regex(\"[a-f0-9]{32}\"):token>/creditnotes/DD001366"

我希望这是一个没有内部正则表达式的漂亮链接(没有任何意义),我认为最好有这样的信用票据项目的链接:

domain.com/creditnotes/DD001366

我尝试更改项目配置,但到目前为止没有运气:

creditnotes = {
'url': 'contracts/<regex("[a-f0-9]{32}"):token>/creditnotes',
'resource_title': 'creditnotes for contract token',
'item_title': 'creditnote',
'item_url': 'regex("[D0-9]{8}")',
'item_lookup': True,
'item_lookup_field': '_id',

# We choose to override global cache-control directives for this resource.
'cache_control': 'max-age=10,must-revalidate',
'cache_expires': 10,

# most global settings can be overridden at resource level
'resource_methods': ['GET'],
'item_methods': ['GET'],
'pagination': False,
# 'item_lookup_field': 'token',

'schema': creditnotes_schema

}

4

1 回答 1

0

是的,这是子资源的一个已知问题。目前,您可能只需关闭HATEOASHATEOAS = False在您的设置文件中)即可解决此问题。

当它在 dev-branch 上修复时,将向该线程添加评论。

于 2014-02-17T09:17:12.470 回答