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

Tagged with:  

One Response to Changing the default URL pattern for REST Services in ColdFusion 10

  1. […] you want to change that, as detailed here, you can modify what URL it’s listening […]

Leave a Reply to ColdFusion 10 and REST: A Primer with Some Nuance – Musings about life and development. Cancel reply

This site uses Akismet to reduce spam. Learn how your comment data is processed.

© 2011 Anuj Gakhar
%d bloggers like this: