In my previous post, I did a very simple REST service using Adobe ColdFusion 10. The way ColdFusion handles REST-enabled services is via a pre-defined Servlet Mapping in web.xml that looks like this :-
[xml]<servlet-mapping id="coldfusion_mapping_15">
<servlet-name>CFRestServlet</servlet-name>
<url-pattern>/rest/*</url-pattern>
</servlet-mapping>[/xml]
This Servlet Mapping has a URL Pattern which tells CF that any URL starting with “/rest” is to be treated as a REST service. However, if you feel the need to change it to something more appropriate, you simply change the url-pattern in {cfroot}/cfusion/wwwroot/WEB-INF/web.xml and restart ColdFusion Server. Here is what my modified Servlet Mapping looks like :-
[xml highlight=”3″]<servlet-mapping id="coldfusion_mapping_15">
<servlet-name>CFRestServlet</servlet-name>
<url-pattern>/api/*</url-pattern>
</servlet-mapping>[/xml]
And I can now call my REST service with this URL http://127.0.0.1:8500/api/RestSample/users
[…] you want to change that, as detailed here, you can modify what URL it’s listening […]