Add function 'get_caps/3'

This commit is contained in:
Feng Lee 2019-09-18 19:46:18 +08:00
parent ad7e0ae436
commit cc79802d6c
1 changed files with 5 additions and 1 deletions

View File

@ -26,6 +26,7 @@
-export([ get_caps/1
, get_caps/2
, get_caps/3
]).
-export([default/0]).
@ -114,10 +115,13 @@ get_caps(Zone) ->
-spec(get_caps(emqx_zone:zone(), publish|subscribe) -> caps()).
get_caps(Zone, publish) ->
with_env(Zone, '$mqtt_pub_caps', fun pub_caps/1);
get_caps(Zone, subscribe) ->
with_env(Zone, '$mqtt_sub_caps', fun sub_caps/1).
-spec(get_caps(emqx_zone:zone(), atom(), term()) -> term()).
get_caps(Zone, Cap, Def) ->
emqx_zone:get_env(Zone, Cap, Def).
pub_caps(Zone) ->
filter_caps(?PUBCAP_KEYS, get_caps(Zone)).