我在创建“灵活”端点时遇到问题。是否有可能沿着这些方向:
# 1) List all Microarrays for this species
/regulatory/species/:species/microarray
sub microarray_list: Chained('species') PathPart('microarray') ActionClass('REST') { }
# 2) Information about a specific array
/regulatory/species/:species/microarray/:microarray
sub microarray_single: Chained('species') PathPart('microarray') CaptureArgs(1) ActionClass('REST') { }
# 3) Information about a probe on the array
/regulatory/species/:species/microarray/:microarray/probe/:probe
sub microarray_probe: Chained('microarray_single') PathPart('probe') Args(1) ActionClass('REST')
启动时 1) 未注册:
| /regulatory/species/*/id/* | /regulatory/species (1) |
| | => /regulatory/id (1) |
| /regulatory/species/*/microarray | /regulatory/species (1) |
| | => /regulatory/microarray_list (...) |
| /regulatory/species/*/microarray/*- | /regulatory/species (1) |
| /probe/* |
任何帮助都将不胜感激!
最佳答案
是的,有可能,您的问题只是您没有 microarray_single 的端点。你可能想要
sub microarray_list :Chained('species') PathPart('microarray')
ActionClass('REST') { }
# this is the chain midpoint, it can load the microarray for the endpoints to use
sub microarray :Chained('species') PathPart('microarray')
CaptureArgs(1) { }
# this is an endpoint with the same path as the midpoint it chains off of
sub microarray_single :Chained('microarray') PathPart('')
Args(0) ActionClass('REST') { }
# and this is an endpoint that adds .../probe/*
sub microarray_probe :Chained('microarray') PathPart('probe')
Args(1) ActionClass('REST') { }
如果 .../microarray/*/probe/*
之后还有其他事情,那么您也可以这样做,将 microarray_probe
从 Args 更改为(1) ActionClass('REST')
(endpoint) to CaptureArgs(1)
,然后用:Chained('microarray_probe') PathPart('') 添加一个端点Args(0) ActionClass('REST')
处理没有额外路径部分的情况。
要牢记的重要一点是,只有链 端点(即没有 CaptureArgs
的操作)对应于有效的 URL 路径。
关于Perl Catalyst Controller 链,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/42433554/