Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Load all plugins API #57

Merged
merged 5 commits into from Mar 13, 2019

Conversation

@turtleDeng
Copy link
Contributor

turtleDeng commented Mar 8, 2019

By adding the -rest_api attribute to the module
The plugin can execute the plugin function via the HTTP API
As follows:

curl http://localhost:8080/api/v3/emqx_plugin_xxx_api/path

-module(emqx_plugin_xxx_api).

-rest_api(#{name   => api_name,
            method => 'GET'| 'POST' | 'PUT' | 'DELETE',
            path   => "plugin_name/path" | "plugin_name/path/:bin:id",
            func   => callback_funtion_name,
            descr  => "API description"}).

-export([callback_function_name/2]).

## Bindings
## If path plugin_name/path/:bin:id
## Bindings is #{id := Id}
## Params is request params
callback_function_name(Bindings, Params) ->
    {ok, [{code, 0}]}.
@turtleDeng turtleDeng closed this Mar 10, 2019
@turtleDeng turtleDeng reopened this Mar 10, 2019
turtleDeng added 4 commits Mar 12, 2019
@turtleDeng turtleDeng merged commit ff54ba3 into develop Mar 13, 2019
0 of 2 checks passed
0 of 2 checks passed
Travis CI - Branch Build Failed
Details
Travis CI - Pull Request Build Failed
Details
@turtleDeng turtleDeng deleted the plugins_api branch Mar 13, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
1 participant
You can’t perform that action at this time.