Skip to content
Jeroen Knoef edited this page Apr 29, 2014 · 2 revisions

Enabling REST for your application is easy using the PathInfoEndPoint:

var ep = new cflow.PathInfoEndPoint();
ep.setRestPaths(["/api"]);
application.context.setEndPoint(ep);

setRestPaths() accepts an array of paths. If the cgi.path_info variable starts with one of these paths, the request is handled as follows:

  • cgi.path_info serves as the target.
  • cgi.request_method serves as the event.

For example, if starting a session is done by a post to /api/session, you can configure this as follows:

<target name="api/session">
    <event type="post">
        <!-- tasks -->
    </event>
</target>

Notice that the name of the target is the same as the path to it (without the leading slash). The post event defines the tasks to be executed for this request.

If a request method has no event defined, the framework reverts to the default event.

Clone this wiki locally