Allow routes to be declared in handlers

Description

Allow developers using SES to declare routes in their event handlers. Allow for a handler-level route, or for action-level routes. Take into consideration all the parameters to addRoute that make sense in this context such as HTTP verbs to match, constraints, pattern, ssl, etcfor handlers but also for actions themselves like this

Example handler Implementation:
/handlers/services/companyProducts.cfc

The following URLs would all work:

Default SES behavior
example.com/index.cfm/services/companyProducts/
example.com/index.cfm/services/companyProducts/index
example.com/index.cfm/services/companyProducts/listProducts

With in-handler routes:
example.com/index.cfm/prod --> services.companyProducts.index
example.com/index.cfm/prod/main --> services.companyProducts.index
example.com/index.cfm/prod/list --> services.companyProducts.listProducts

Activity

Show:
Joel Tobey
December 30, 2017, 3:38 PM

I was thinking of creating a module to do just this. If it's going to be in the core, I'm happy to work on this.

Proposal: Should the default behavior also work if you add in-handler routes? I don't think so. I think when you define a route in the handler annotation, it should override the default behavior. It would clear up confusion about which URL to use. If there are concerns of backward compatibility or other forwarding issues, perhaps we provide a 'redirectConventialRoute' annotation (or some other clever name) that defaults to 'true' and does a 301 Moved Permanently redirect. If the flag is set to false, then both URLs would work.

Luis Majano
April 13, 2018, 10:09 PM

I think we can start it as an incubation module and if it merits, then bake it into the core.

Assignee

Luis Majano

Reporter

Brad Wood

Labels

None

Epic Link

Priority

Major
Configure