I have two problems:
#1 First issue
Two routes in my Router.cfc:
get(
"/products"
).to( "ProductController.search" ).end();
get(
"/products/:id"
).to( "ProductController.get" ).end();
if i call:
http://localhost:62566/api/products/myId
router fires the first route (with “search” method). I expected for the second (with myId param after /products/)
If I reverse the two routes, it works fine.
I tried playing with:
setFullRewrites( true );
setLooseMatching( true );
but it doesn’t change anything.
I don’t understand if it’s correct behavior or a bug.
In Apache I have to use the string start (^) and string end ($) characters for an exact search of the string, or the character “=” before matching pattern.
#2 Second issue
This configuration of my Router.cfc causes an error:
get(
"/products"
).to( "ProductController.search" ).end();
post(
"/products"
).to('ProductController.create').end();
As you see, I have same url (“/products”) with different handler and verbs.
I call:
http://localhost:62566/api/products
I get this error:
EventHandlerNotRegisteredException
The event: ProductController.search is not a valid registered event.
If i change the verb or the url it works correctly.
I only encounter this problem inside a module.
Here you can download a test package.
Simple, from CommandBox, as you know:
install
server start
then point your browser to:
http://localhost:62566/api/products
I work with:
- this.nullSupport = false;
- Coldbox 7.0.0.2
- Lucee: 5.4.0+80
Thank you very much.