Просмотр исходного кода

fix: don't require path in http action(fill default path)

zhongwencool 2 лет назад
Родитель
Сommit
cd1365d753

+ 1 - 1
apps/emqx_bridge_http/src/emqx_bridge_http_action_info.erl

@@ -67,7 +67,7 @@ connector_action_config_to_bridge_v1_config(ConnectorConfig, ActionConfig) ->
     }.
 
 bridge_v1_config_to_connector_config(BridgeV1Conf) ->
-    %% To statisfy the emqx_bridge_api_SUITE:t_http_crud_apis/1
+    %% To satisfy the emqx_bridge_api_SUITE:t_http_crud_apis/1
     ok = validate_webhook_url(maps:get(<<"url">>, BridgeV1Conf, undefined)),
     maps:without(?REMOVED_KEYS ++ ?ACTION_KEYS ++ ?PARAMETER_KEYS, BridgeV1Conf).
 

+ 2 - 6
apps/emqx_bridge_http/src/emqx_bridge_http_connector.erl

@@ -565,12 +565,8 @@ preprocess_request(undefined) ->
     undefined;
 preprocess_request(Req) when map_size(Req) == 0 ->
     undefined;
-preprocess_request(
-    #{
-        method := Method,
-        path := Path
-    } = Req
-) ->
+preprocess_request(#{method := Method} = Req) ->
+    Path = maps:get(path, Req, <<>>),
     Headers = maps:get(headers, Req, []),
     #{
         method => parse_template(to_bin(Method)),