Railo Environment
- Railo web.xml
- Railo runs a separate servlet for ReST requests. This is where the '/rest' of the URL is definded
- Wiki documentation for Railo web.xml
- If you have a dedicated Railo server for your ReST API and dont like the '/rest' in the URL, you can change the mapping to just '/'
- You need to tell Railo where to look for the CFCs for your ReST API
- Railo Admin - server or web context under 'Archives & Resources'
- /railo-context/admin/web.cfm?action=resources.rest
- virtual is the name of the API, eg 'api'
- physical path the CFCs
- URL to the API starts with /rest/<virtual-name> eg /rest/api
- mapping in code (password required)
- use RestInitApplication()
- Railo Admin - server or web context under 'Archives & Resources'
- when adding new component / function you will need Railo to rescan your CFCs
- save in railo admin
- selected mapping and click save
- in code
- application.cfc onRequestStart() call RestInitApplication()
- to speed up requests, wrap this in rest for URL.reset=true
- save in railo admin
Test Code
Here is some code that you should be able to drop into your web root and run.
<your-server>/rest-tutorials/index.cfm
You will need to set you web context password in
rest-tutorials/Application.cfc
this.webAdminPassword = 'server';
Note:
You will see in demo 2 that the ReST API has it's own APPLICATION scope.