BoxLang 🚀 A New JVM Dynamic Language Learn More...

Reserved Routes

v1 Interceptors
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).


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'} },

$ box install Reserved-Routes

No collaborators yet.
 
3.00 / 2
  • {{ getFullDate("2009-12-29T21:58:43Z") }}
  • {{ getFullDate("2016-06-09T15:24:09Z") }}
  • 8,006
  • 4,826