-
Notifications
You must be signed in to change notification settings - Fork 36
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
Is there an easy way to modify web_hook to allow changing message data? #118
Comments
Yes, you can't update any content of a publish message by the official emqx_web_hook. So, if want using web_hook to implement this, maybe you should receive the HTTP response to update the message content in the i.e: on_message_publish(Message = #message{topic = Topic, flags = #{retain := Retain}}, {Filter}) ->
with_filter(
fun() ->
{FromClientId, FromUsername} = format_from(Message),
Params = [{action, message_publish},
{from_client_id, FromClientId},
{from_username, FromUsername},
{topic, Message#message.topic},
{qos, Message#message.qos},
{retain, Retain},
{payload, Message#message.payload},
{ts, emqx_time:now_secs(Message#message.timestamp)}],
%% Modify these lines:
%% send_http_request(Params),
%% {ok, Message}
%% To:
Response = send_http_request(Params),
NewMessage = parse_http_resp_to_message(Response, Message),
{ok, NewMessage}
end, Message, Topic, Filter). But, you should understand the Hooks Mechnism and Erlang first! |
Still not possible? @HJianBo This request was old, maybe in the meantime things changed :) I saw this here: https://www.emqx.com/en/blog/develop-emqx-plugin-using-python Use-Case: appending a timestamp to JSON-payloads. thanks! :) |
nvm, found this here: https://github.com/emqx/emqx-extension-examples/tree/master/exhook-svr-go works fine! thanks! |
I need to modify publishes in-flight from Python. I was hoping web_hook would let me do that, but then I saw this ticket that said that only lua can do that.
I plan to deploy the authentication, authorization, and modification service alongside the broker, and its very important for my application that I can manipulate those messages. In the issue above someone says its possible to modify the web_hook extension to modify data.
I don't know erlang. I could learn it, but it would take some time. Is there a simple example for how to modify the web_hook extension to modify the payload on a publish based on the results of the http call? I understand if this isn't a trivial task, thanks for your time.
The text was updated successfully, but these errors were encountered: