-
Notifications
You must be signed in to change notification settings - Fork 3
REST
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_infoserves as the target. -
cgi.request_methodserves 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.