fix(authn): fix type error for http headers
This commit is contained in:
parent
b07e686350
commit
6b521acd6f
|
@ -226,7 +226,7 @@ do_pre_config_update({move_authenticator, _ChainName, AuthenticatorID, Position}
|
||||||
end
|
end
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec post_config_update(update_request, map() | list(), emqx_config:raw_config(), emqx_config:app_envs())
|
-spec post_config_update(update_request(), map() | list(), emqx_config:raw_config(), emqx_config:app_envs())
|
||||||
-> ok | {ok, map()} | {error, term()}.
|
-> ok | {ok, map()} | {error, term()}.
|
||||||
post_config_update(UpdateReq, NewConfig, OldConfig, AppEnvs) ->
|
post_config_update(UpdateReq, NewConfig, OldConfig, AppEnvs) ->
|
||||||
do_post_config_update(UpdateReq, check_config(to_list(NewConfig)), OldConfig, AppEnvs).
|
do_post_config_update(UpdateReq, check_config(to_list(NewConfig)), OldConfig, AppEnvs).
|
||||||
|
|
|
@ -214,7 +214,7 @@ default_headers_no_content_type() ->
|
||||||
|
|
||||||
transform_header_name(Headers) ->
|
transform_header_name(Headers) ->
|
||||||
maps:fold(fun(K0, V, Acc) ->
|
maps:fold(fun(K0, V, Acc) ->
|
||||||
K = list_to_binary(string:to_lower(binary_to_list(K0))),
|
K = list_to_binary(string:to_lower(to_list(K0))),
|
||||||
maps:put(K, V, Acc)
|
maps:put(K, V, Acc)
|
||||||
end, #{}, Headers).
|
end, #{}, Headers).
|
||||||
|
|
||||||
|
@ -301,3 +301,8 @@ parse_body(<<"application/x-www-form-urlencoded">>, Body) ->
|
||||||
{ok, maps:from_list(cow_qs:parse_qs(Body))};
|
{ok, maps:from_list(cow_qs:parse_qs(Body))};
|
||||||
parse_body(ContentType, _) ->
|
parse_body(ContentType, _) ->
|
||||||
{error, {unsupported_content_type, ContentType}}.
|
{error, {unsupported_content_type, ContentType}}.
|
||||||
|
|
||||||
|
to_list(A) when is_atom(A) ->
|
||||||
|
atom_to_list(A);
|
||||||
|
to_list(B) when is_binary(B) ->
|
||||||
|
binary_to_list(B).
|
||||||
|
|
|
@ -66,7 +66,7 @@ fields(http_get) ->
|
||||||
},
|
},
|
||||||
converter => fun (Headers0) ->
|
converter => fun (Headers0) ->
|
||||||
Headers1 = maps:fold(fun(K0, V, AccIn) ->
|
Headers1 = maps:fold(fun(K0, V, AccIn) ->
|
||||||
K1 = iolist_to_binary(string:to_lower(binary_to_list(K0))),
|
K1 = iolist_to_binary(string:to_lower(to_list(K0))),
|
||||||
maps:put(K1, V, AccIn)
|
maps:put(K1, V, AccIn)
|
||||||
end, #{}, Headers0),
|
end, #{}, Headers0),
|
||||||
maps:merge(#{ <<"accept">> => <<"application/json">>
|
maps:merge(#{ <<"accept">> => <<"application/json">>
|
||||||
|
@ -177,3 +177,8 @@ connector_fields(DB, Fields) ->
|
||||||
, {enable, #{type => boolean(),
|
, {enable, #{type => boolean(),
|
||||||
default => true}}
|
default => true}}
|
||||||
] ++ Mod:fields(Fields).
|
] ++ Mod:fields(Fields).
|
||||||
|
|
||||||
|
to_list(A) when is_atom(A) ->
|
||||||
|
atom_to_list(A);
|
||||||
|
to_list(B) when is_binary(B) ->
|
||||||
|
binary_to_list(B).
|
Loading…
Reference in New Issue