feat(http): add `is_template` as HTTP headers field property

is_template was designed to be type property.
however for HTTP headers, it's a map() type,
instead of creating a new type for it, it's easier to just
add it as a field property.
This commit is contained in:
zmstone 2024-04-18 13:16:29 +02:00
parent ede4eeae9f
commit 5b38d592f0
3 changed files with 9 additions and 3 deletions

View File

@ -130,7 +130,8 @@ fields("request") ->
})}, })},
{path, hoconsc:mk(emqx_schema:template(), #{required => false, desc => ?DESC("path")})}, {path, hoconsc:mk(emqx_schema:template(), #{required => false, desc => ?DESC("path")})},
{body, hoconsc:mk(emqx_schema:template(), #{required => false, desc => ?DESC("body")})}, {body, hoconsc:mk(emqx_schema:template(), #{required => false, desc => ?DESC("body")})},
{headers, hoconsc:mk(map(), #{required => false, desc => ?DESC("headers")})}, {headers,
hoconsc:mk(map(), #{required => false, desc => ?DESC("headers"), is_template => true})},
{max_retries, {max_retries,
sc( sc(
non_neg_integer(), non_neg_integer(),

View File

@ -270,7 +270,8 @@ headers_field() ->
<<"content-type">> => <<"application/json">>, <<"content-type">> => <<"application/json">>,
<<"keep-alive">> => <<"timeout=5">> <<"keep-alive">> => <<"timeout=5">>
}, },
desc => ?DESC("config_headers") desc => ?DESC("config_headers"),
is_template => true
} }
)}. )}.

View File

@ -57,7 +57,11 @@
allowEmptyValue, allowEmptyValue,
deprecated, deprecated,
minimum, minimum,
maximum maximum,
%% is_template is a type property,
%% but some exceptions are made for them to be field property
%% for example, HTTP headers (which is a map type)
is_template
]). ]).
-define(INIT_SCHEMA, #{ -define(INIT_SCHEMA, #{