Go to page content


Processes authorized REST API requests

resource_api by default listens at the url /api/:module/:method and the url /api/:module. On this URL, a lookup is done to the module named mod_module in its services directory, for a Erlang file called service_module_method.erl. If method is left empty (at the /api/:module url), the method name equals the module name.

So for example the following lookups result in the following service handlers:

URLmodulemethodFound service .erl file

These examples are already existing as Zotonic API calls that you can use.

Creating REST services at other URLs

Since 0.8, it is possible to pre-fill these module and method parameters so that you can use resource_api at another URL entry point. For instance, the following URL is valid:

    {dosomething,    ["do", "something"], resource_api, [{module, "foobar"}, {method, "test"}]}

This would invoke the foobar/services/service_foobar_test.erl service at the url /do/something,

This page is part of the Zotonic documentation, which is licensed under the Apache License 2.0.