Reserved Routes

The Reserved Routes interceptor is quite simple but helpful. It should be loaded in your applicatons ColdBox Config file after the SES Interceptor. It then pulls the SES interceptor from the ColdBox Cache, extracts the routes and reserves any static strings in the first position of your URL.


EXAMPLE OF STATIC ROUTE RESERVATON
  • addRoute(pattern='about/:version?', handler='General', action='index');
  • The above route declaration would result in the ReservedRoutes interceptor generating a reserved string of 'about'.
DYNAMIC FIRST POSITION ROUTES ARE NOT RESERVED
  • addRoute(':handler/:action?');
  • The above route declaration would not result in any reserved strings as the first element in the list is dynamic.
WHY WAS THIS INTERCEPTOR CREATED
This interceptor was created to allow users to have their own URLs such as mywebsite.com/:username. During the registration process, their username is compared to my reserved routes. I also add additional strings to the reserved list to exclude words I do not wish users to have (such as bad words).


box install Reserved-Routes
 

CommandBox Dependency

Add the following to your dependencies or devdependencies json, so CommandBox can track it as a project dependency. "Reserved-Routes" : "1"

Stats

aarongreenlee@gmail.com's Gravatar   Aaron Greenlee Dec 29, 2009 at 9:58 PM Dec 18, 2014 at 8:33 AM 1 3 Interceptors 4064 1310 0

Installation Instructions

Step 1
Add the interceptor to your ColdBox config AFTER the SES interceptor.
//SES {class="coldbox.system.interceptors.SES", properties={} }, //RESERVE SES ROUTES {class="interceptors.ReserveRoutes", properties={} }
Step 2:When you need to get your reserved routes, just use the getSetting('ReservedRoutes'); syntax

Optional
When you declare the interceptor in the ColdBox configuration file, you can provide a list of custom terms to reserve, Example: {class="interceptors.ReserveRoutes", properties={custom='DontAllowThisWord,SomethingUnacceptable,Dont-Allow-This-Work,Or-This-One'} },

Google+