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 :-

<servlet-mapping id="coldfusion_mapping_15">
    <servlet-name>CFRestServlet</servlet-name>
    <url-pattern>/rest/*</url-pattern>
</servlet-mapping>

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 :-

<servlet-mapping id="coldfusion_mapping_15">
   <servlet-name>CFRestServlet</servlet-name>
   <url-pattern>/api/*</url-pattern>
</servlet-mapping>

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

Subscribe to Blog via Email

Enter your email address to subscribe to this blog and receive notifications of new posts by email.

Join 292 other subscribers

© 2011 Anuj Gakhar
%d bloggers like this: