framework-one / fw1

FW/1 - Framework One - is a lightweight, convention over configuration, MVC application framework for ColdFusion / CFML.
http://framework-one.github.io
Other
373 stars 141 forks source link

Subsystem and Search Engine Friendly URL #534

Closed doodi-v1 closed 3 years ago

doodi-v1 commented 3 years ago

I'm using both subsystem and SEF (SEO) URLs for the first time so this could simply be me. I'm creating a rest server and want to support versioning in the URL endpoint and using FW1 subsystem seems like a perfect fit. I have defined v1 & v2 subsystems. https://[domain.com]/index.cfm?action=v1:rest.prauth and https://[domain.com]/index.cfm?action=v2:rest.prauth both work as intended. But I found that https://[domain.com]/v1/rest/preauth does not. Instead I need to specify https://[domain.com]/v1:rest/preauth. I am not able to set subsystemDelimiter to '/'. Is this intentional, or should I be able to use a forward slash? (no error, it just seems to get confused, probably fighting with subsystem vs. system vs. attributes.

matthewjones commented 3 years ago

I tend to use routes to specify the version and pass that in, I generally don't have enough change between versions to feel it would warrant a new subsystem though. So i just use it to set a variable, but you could definitely use routes to reference alternate subsystems.

tonyjunkes commented 3 years ago

This sounds like a job for FW/1's routing functionality.

http://framework-one.github.io/documentation/4.3/developing-applications/#url-routes

In your framework settings in Application.cfc you would have something like this for matching your convention path and any parameters.

// ... other framework settings ...
routes: [
    { "/v1/rest/preauth" = "/v1:rest/preauth" } // index.cfm?action=v1:rest.preauth
]

The above example makes http://mydomain.com/index.cfm/v1/rest/preauth point to your subsystem/controller/method. In order to omit the index.cfm in the URL, you'll want to look into having the web server handle that with a rewrite.

doodi-v1 commented 3 years ago

Thank you both. I used subsystems for the first time, and now routes for the first time. For such a simple framework, the built in features keep me amazed.

BTW, is there a FW1 forum or users group somewhere for questions like these? "Issues" does not seem right.

tonyjunkes commented 3 years ago

I would join the CFML Slack https://cfml-slack.herokuapp.com/

There's an FW/1 channel, among others, where you can ask questions etc.