Pecan default routing algorithm fails to find the requested resource
when the requested URL contains keywords that match the name of any
method declared inside of a pecan controller decorated with the
@expose(generic=True, ...) or @index.when() decorators.
This commit implements a custom routing through the use of pecan's
_route() method, where the routing is redirected to the generic index
method, allowing the keywords to be correctly passed as arguments to
the correct method handler based on the request method (GET, POST,
PATCH, DELETE, etc.).
Test plan:
PASS: Execute all of the subcloud-group sub-commands (add, delete, list,
list-subclouds, show and update) with the following group names: get,
post, patch, delete, index, _validate_name, _route and foo.
Reviewed: https:/ /review. opendev. org/c/starlingx /distcloud/ +/864414 /opendev. org/starlingx/ distcloud/ commit/ 00f5a5361151b27 9dea7a932f74afb 1465483800
Committed: https:/
Submitter: "Zuul (22348)"
Branch: master
commit 00f5a5361151b27 9dea7a932f74afb 1465483800
Author: Gustavo Herzmann <email address hidden>
Date: Mon Nov 14 11:05:52 2022 -0300
Fix subcloud-group endpoint routing conflict
Pecan default routing algorithm fails to find the requested resource generic= True, ...) or @index.when() decorators.
when the requested URL contains keywords that match the name of any
method declared inside of a pecan controller decorated with the
@expose(
This commit implements a custom routing through the use of pecan's
_route() method, where the routing is redirected to the generic index
method, allowing the keywords to be correctly passed as arguments to
the correct method handler based on the request method (GET, POST,
PATCH, DELETE, etc.).
Test plan:
PASS: Execute all of the subcloud-group sub-commands (add, delete, list,
list-subclouds, show and update) with the following group names: get,
post, patch, delete, index, _validate_name, _route and foo.
Closes-Bug: #1996507
Signed-off-by: Gustavo Herzmann <email address hidden> 5b68ee4199fb339 776dd3d8dde
Change-Id: I98a22f2bf1da20