chore(auhtn): keep one ssl opts checking func
This commit is contained in:
parent
df92a60085
commit
5bb55332a5
|
@ -72,7 +72,7 @@ common_fields() ->
|
||||||
] ++ proplists:delete(base_url, emqx_connector_http:fields(config)).
|
] ++ proplists:delete(base_url, emqx_connector_http:fields(config)).
|
||||||
|
|
||||||
validations() ->
|
validations() ->
|
||||||
[ {check_ssl_opts, fun check_ssl_opts/1} ].
|
[ {check_ssl_opts, fun emqx_connector_http:check_ssl_opts/1} ].
|
||||||
|
|
||||||
url(type) -> binary();
|
url(type) -> binary();
|
||||||
url(nullable) -> false;
|
url(nullable) -> false;
|
||||||
|
@ -190,17 +190,6 @@ check_form_data(FormData) ->
|
||||||
false
|
false
|
||||||
end.
|
end.
|
||||||
|
|
||||||
check_ssl_opts(Conf) ->
|
|
||||||
URL = hocon_schema:get_value("url", Conf),
|
|
||||||
{ok, #{scheme := Scheme}} = emqx_http_lib:uri_parse(URL),
|
|
||||||
SSLOpts = hocon_schema:get_value("ssl_opts", Conf),
|
|
||||||
case {Scheme, SSLOpts} of
|
|
||||||
{http, undefined} -> true;
|
|
||||||
{http, _} -> false;
|
|
||||||
{https, undefined} -> false;
|
|
||||||
{https, _} -> true
|
|
||||||
end.
|
|
||||||
|
|
||||||
preprocess_form_data(FormData) ->
|
preprocess_form_data(FormData) ->
|
||||||
KVs = binary:split(FormData, [<<"&">>], [global]),
|
KVs = binary:split(FormData, [<<"&">>], [global]),
|
||||||
[list_to_tuple(binary:split(KV, [<<"=">>], [global])) || KV <- KVs].
|
[list_to_tuple(binary:split(KV, [<<"=">>], [global])) || KV <- KVs].
|
||||||
|
|
|
@ -32,6 +32,8 @@
|
||||||
, fields/1
|
, fields/1
|
||||||
, validations/0]).
|
, validations/0]).
|
||||||
|
|
||||||
|
-export([ check_ssl_opts/1 ]).
|
||||||
|
|
||||||
-type connect_timeout() :: non_neg_integer() | infinity.
|
-type connect_timeout() :: non_neg_integer() | infinity.
|
||||||
-type pool_type() :: random | hash.
|
-type pool_type() :: random | hash.
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue