Sam Scott
03/09/2022, 6:59 PM// User Resource
route( "/api/v1/user/:userID" )
.withAction( {
GET = 'view',
POST = 'save',
PUT = 'save',
DELETE = 'remove'
} )
.toHandler( "api.v1.user" );
For example, a PUT to the conventional URL works: /api/v1/user/save/userid/55
But, a PUT to /api/v1/user/55
throws an error with message "Action '55' could not be found". Which means coldbox skipped right over the route definition, right?sknowlton
03/09/2022, 7:02 PMroute( "/api/v1/user")
above that route you listed, it will match that one firstsknowlton
03/09/2022, 7:02 PMsknowlton
03/09/2022, 7:03 PMv1
module I don't think you need api.v1.user
for toHandler
- just user
sknowlton
03/09/2022, 7:03 PMSam Scott
03/09/2022, 7:06 PMsknowlton
03/09/2022, 7:07 PMSam Scott
03/09/2022, 7:21 PMroute( "/:handler/:action" ).end();
line in /config/Router.cfc and make sure the v1 file has that as the last line, correct?Sam Scott
03/09/2022, 10:14 PMSam Scott
03/09/2022, 10:16 PMsknowlton
03/09/2022, 10:19 PMSam Scott
03/09/2022, 10:24 PM// User Resource
route( "/api/v1/user/:userID" )
.withAction( {
GET = 'view',
POST = 'save',
PUT = 'save',
DELETE = 'remove'
} )
.toHandler( "v1:user" );
TO...
// User Resource
route( "/who/:userID" )
.withAction( {
GET = 'view',
POST = 'save',
PUT = 'save',
DELETE = 'remove'
} )
.toHandler( "v1:user" );
POST to URL "/who/55" works fine and is mapped to /api/v1/user/save/userID/55
routes defined with "api/v1/user/:userID" do not match the URL /api/v1/user/55 even though it looks like it should in route-visualizer. Instead that URL is caught by the default handler/action/ route.
I'll keep playing and reading but I feel like I'm missing or not understanding some fundamental piece of routing in coldbox.sknowlton
03/09/2022, 10:27 PMapi/v1
part of the route. That should be the route to the module, not to the event. All of our routes are part of our v1 Router.cfc and look like
.route( "/eligibilityRules" )
.withAction( {
GET = 'list'
})
.toHandler( "eligibilityRules" )
There isn't any reference to the module path.sknowlton
03/09/2022, 10:28 PMSam Scott
03/09/2022, 10:28 PM// API Authentication Routes
post( "/login", "Auth.login" );
post( "/logout", "Auth.logout" );
post( "/register", "Auth.register" );
// API Secured Routes
get( "/whoami", "Echo.whoami" );
...aren't loaded into coldbox (at least not visible in route-visualizer) and routes don't worksknowlton
03/09/2022, 10:28 PMSam Scott
03/09/2022, 10:28 PMsknowlton
03/09/2022, 10:30 PMSam Scott
03/09/2022, 10:30 PMSam Scott
03/09/2022, 10:30 PMSam Scott
03/09/2022, 10:34 PMcoldbox create app skeleton="rest-hmvc"
server start --rewritesEnable
the v1 module config/Router.cfc doesn't get loaded and routes defined in it don't work and I can't figure out why. The only routes that work are in the root /config/Router.cfc that contains the /healthcheck route and the default conventions route.cfvonner
03/09/2022, 11:54 PMthis.entryPoint = "/mymodule";
?Sam Scott
03/09/2022, 11:55 PMSam Scott
03/09/2022, 11:55 PMcfvonner
03/09/2022, 11:56 PMapi
module probably needs this.entryPoint = "/api";
and your api/v1
module probably needs this.entryPoint = "/v1";
or maybe this.entryPoint = "/api/v1";
(not sure which).Sam Scott
03/09/2022, 11:56 PMSam Scott
03/09/2022, 11:57 PMSam Scott
03/09/2022, 11:58 PMSam Scott
03/09/2022, 11:59 PMSam Scott
03/10/2022, 12:02 AMSam Scott
03/10/2022, 12:29 AMSam Scott
03/10/2022, 6:23 PM