Perl Catalyst控制器链
我在创建“灵活”端点时遇到问题。是否有可能做到这一点:Perl Catalyst控制器链,perl,endpoint,chaining,catalyst,Perl,Endpoint,Chaining,Catalyst,我在创建“灵活”端点时遇到问题。是否有可能做到这一点: # 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
# 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/* |
非常感谢您的帮助 是的,这是可能的,你的问题只是你没有一个微阵列的终点。你可能想要
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\u probe
从Args(1)ActionClass('REST')
(端点)更改为CaptureArgs(1)
,然后添加带有:Chained('microarray\u probe')PathPart('')Args(0)ActionClass的端点('REST')
处理没有其他路径部分的情况
需要记住的重要一点是,只有链端点(即没有
CaptureArgs
的操作)对应于有效的URL路径。哪里定义了/regulatory/species/*/id/*
?