Skip to content


Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
branch: master
Fetching contributors…

Cannot retrieve contributors at this time

146 lines (110 sloc) 2.558 kb
// Param the HTTP method to test with.
name = "url.httpMethod"
type = "string"
default = "GET"
// Param the resource uri.
name = "url.resourceUri"
type = "string"
default = ""
// Create an instance of our resource mapper. When we instantiate it,
// we can define a default param name. This is the name of the param
// that is created if we pass-in a string as our resource params
// argument when defining routes.
resourceMapper = new lib.ResourceMapper( defaultParamName = "event" );
// Let's define our resources / routes. When defining resources,
// can use both the individual HTTP method methods (ie. get, put,
// post, delet). Or, we can use a then when() method and define
// the HTTP verbs as properties.
get = "blog.getComments",
post = "blog.addComment"
event = "",
archive = true
// Check to see if a resource has been defined.
if ( len( url.resourceUri ) ) {
resourceResolution = resourceMapper.resolveResource(
httpMethod = url.httpMethod,
resourceUri = url.resourceUri
// Define some resources to demo.
demoResources = [
<!--- Reset the output buffer. --->
<cfcontent type="text/html" />
<!doctype html>
<meta charset="utf-8" />
<!--- Output each demo resource using GET and POST. --->
<a href="#cgi.script_name#?httpMethod=GET&resourceUri=#urlEncodedFormat( demoResource )#">GET #demoResource#</a>
<a href="#cgi.script_name#?httpMethod=POST&resourceUri=#urlEncodedFormat( demoResource )#">POST #demoResource#</a>
<!--- Check to see if we have a resolution. --->
<cfif len( url.resourceUri )>
Resource Resolution
<cfif isNull( resourceResolution )>
Sorry, the resource could not be found.
label="Resource Resolution"
Jump to Line
Something went wrong with that request. Please try again.