-
Notifications
You must be signed in to change notification settings - Fork 429
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Rework HTTP handler configuration #3636
Conversation
Codecov Report
@@ Coverage Diff @@
## master #3636 +/- ##
=======================================
Coverage 81.03% 81.04%
=======================================
Files 427 428 +1
Lines 31962 31939 -23
=======================================
- Hits 25901 25884 -17
+ Misses 6061 6055 -6
Continue to review full report at Codecov.
|
This comment was marked as outdated.
This comment was marked as outdated.
196475b
to
bcd1683
Compare
This comment was marked as outdated.
This comment was marked as outdated.
bcd1683
to
10c6f17
Compare
This comment was marked as outdated.
This comment was marked as outdated.
It will be handled by mongoose_config_handler.
The goal is better separation between specs and utils
dbbefc5
to
f534527
Compare
This comment was marked as outdated.
This comment was marked as outdated.
small_tests_24 / small_tests / f534527 small_tests_23 / small_tests / f534527 dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / f534527 dynamic_domains_mysql_redis_24 / mysql_redis / f534527 dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / f534527 dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / f534527 ldap_mnesia_24 / ldap_mnesia / f534527 ldap_mnesia_23 / ldap_mnesia / f534527 internal_mnesia_24 / internal_mnesia / f534527 pgsql_mnesia_23 / pgsql_mnesia / f534527 pgsql_mnesia_24 / pgsql_mnesia / f534527 mysql_redis_24 / mysql_redis / f534527 elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / f534527 mssql_mnesia_24 / odbc_mssql_mnesia / f534527 riak_mnesia_24 / riak_mnesia / f534527 pubsub_SUITE:dag+basic:publish_test{error,{{badmatch,false},
[{pubsub_tools,check_response,2,
[{file,"/home/circleci/project/big_tests/tests/pubsub_tools.erl"},
{line,491}]},
{pubsub_tools,receive_response,3,
[{file,"/home/circleci/project/big_tests/tests/pubsub_tools.erl"},
{line,481}]},
{pubsub_tools,receive_and_check_response,4,
[{file,"/home/circleci/project/big_tests/tests/pubsub_tools.erl"},
{line,471}]},
{escalus_story,story,4,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,72}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1292}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1224}]}]}} |
f534527
to
f7f6e3c
Compare
small_tests_24 / small_tests / f7f6e3c small_tests_23 / small_tests / f7f6e3c dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / f7f6e3c dynamic_domains_mysql_redis_24 / mysql_redis / f7f6e3c dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / f7f6e3c dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / f7f6e3c ldap_mnesia_23 / ldap_mnesia / f7f6e3c ldap_mnesia_24 / ldap_mnesia / f7f6e3c internal_mnesia_24 / internal_mnesia / f7f6e3c pgsql_mnesia_23 / pgsql_mnesia / f7f6e3c elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / f7f6e3c mysql_redis_24 / mysql_redis / f7f6e3c pgsql_mnesia_24 / pgsql_mnesia / f7f6e3c mssql_mnesia_24 / odbc_mssql_mnesia / f7f6e3c riak_mnesia_24 / riak_mnesia / f7f6e3c |
API: - config_spec/0 returns the config section spec for all possible HTTP handlers - get_routes/1 returns Cowboy routes for a list of configured handlers There are two optional callbacks: - config_spec/0 returning config specification for the handler, if it has any options - routes/1 returning Cowboy routes, if different from the default All handlers which have options should be listed in configurable_handler_modules/0
Use maps with defaults in the config spec
Use maps with defaults, include all handlers by default
- Use maps with defaults for options
Expect options in a map
- Use maps with defaults - Include all handlers by default New options: - 'handlers' - to choose specific low-level handlers, - 'docs' - to disable docs.
It will be placed in mongoose_http_handler Also: refactor 'store_trails'
- Use maps with defaults - Add new options - Rework test layout after reworking mongoose_client_api config - Remove the custom logic for comparing handler tuples
f7f6e3c
to
cf739ba
Compare
- Simplify examples to match the defaults in mongooseim.toml - Document the new options: `handlers` and `docs` - Update the list of available handlers
cf739ba
to
8367450
Compare
small_tests_24 / small_tests / cf739ba small_tests_23 / small_tests / cf739ba dynamic_domains_mysql_redis_24 / mysql_redis / cf739ba dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / cf739ba dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / cf739ba dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / cf739ba ldap_mnesia_24 / ldap_mnesia / cf739ba ldap_mnesia_23 / ldap_mnesia / cf739ba internal_mnesia_24 / internal_mnesia / cf739ba elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / cf739ba pgsql_mnesia_23 / pgsql_mnesia / cf739ba pgsql_mnesia_24 / pgsql_mnesia / cf739ba mysql_redis_24 / mysql_redis / cf739ba mssql_mnesia_24 / odbc_mssql_mnesia / cf739ba pep_SUITE:pep_tests:delayed_receive{error,{{badmatch,[]},
[{pep_SUITE,'-delayed_receive/1-fun-0-',3,
[{file,"/home/circleci/project/big_tests/tests/pep_SUITE.erl"},
{line,276}]},
{escalus_story,story,4,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,72}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1292}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1224}]}]}} pep_SUITE:pep_tests:send_caps_after_login_test{error,{{assertion_failed,assert_many,false,[is_roster_set,is_presence],[],[]},
[{escalus_new_assert,assert_true,2,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_new_assert.erl"},
{line,84}]},
{escalus_story,'-make_all_clients_friends/1-fun-0-',2,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,111}]},
{escalus_utils,'-each_with_index/3-fun-0-',3,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_utils.erl"},
{line,87}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1267}]},
{escalus_utils,'-each_with_index/3-fun-0-',3,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_utils.erl"},
{line,87}]},
{lists,foldl,3,[{file,"lists.erl"},{line,1267}]},
{escalus_utils,distinct_pairs,2,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_utils.erl"},
{line,60}]},
{escalus_story,make_all_clients_friends,1,
[{file,"/home/circleci/project/big_tests/_build/default/lib/escalus/src/escalus_story.erl"},
{line,106}]}]}} riak_mnesia_24 / riak_mnesia / cf739ba |
small_tests_24 / small_tests / 8367450 small_tests_23 / small_tests / 8367450 dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 8367450 bosh_SUITE:essential_https:accept_higher_hold_value{error,
{{assertEqual,
[{module,bosh_SUITE},
{line,251},
{expression,"get_bosh_sessions ( )"},
{expected,[]},
{value,
[{bosh_session,<<"3da36d68bc677101cd293eaa35be988999384039">>,
<8633.6002.0>}]}]},
[{bosh_SUITE,accept_higher_hold_value,1,
[{file,"/home/circleci/project/big_tests/tests/bosh_SUITE.erl"},
{line,251}]},
{test_server,ts_tc,3,[{file,"test_server.erl"},{line,1783}]},
{test_server,run_test_case_eval1,6,
[{file,"test_server.erl"},{line,1292}]},
{test_server,run_test_case_eval,9,
[{file,"test_server.erl"},{line,1224}]}]}} dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / 8367450 dynamic_domains_mysql_redis_24 / mysql_redis / 8367450 dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / 8367450 ldap_mnesia_23 / ldap_mnesia / 8367450 ldap_mnesia_24 / ldap_mnesia / 8367450 internal_mnesia_24 / internal_mnesia / 8367450 pgsql_mnesia_24 / pgsql_mnesia / 8367450 elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / 8367450 mysql_redis_24 / mysql_redis / 8367450 mssql_mnesia_24 / odbc_mssql_mnesia / 8367450 riak_mnesia_24 / riak_mnesia / 8367450 dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / 8367450 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
All looks good to me :) I like the changes, the code and config look clearer now. I added minor comments about formatting.
small_tests_24 / small_tests / eeda654 small_tests_23 / small_tests / eeda654 dynamic_domains_pgsql_mnesia_23 / pgsql_mnesia / eeda654 dynamic_domains_pgsql_mnesia_24 / pgsql_mnesia / eeda654 dynamic_domains_mysql_redis_24 / mysql_redis / eeda654 ldap_mnesia_24 / ldap_mnesia / eeda654 ldap_mnesia_23 / ldap_mnesia / eeda654 dynamic_domains_mssql_mnesia_24 / odbc_mssql_mnesia / eeda654 internal_mnesia_24 / internal_mnesia / eeda654 mysql_redis_24 / mysql_redis / eeda654 pgsql_mnesia_24 / pgsql_mnesia / eeda654 pgsql_mnesia_23 / pgsql_mnesia / eeda654 elasticsearch_and_cassandra_24 / elasticsearch_and_cassandra_mnesia / eeda654 mssql_mnesia_24 / odbc_mssql_mnesia / eeda654 riak_mnesia_24 / riak_mnesia / eeda654 |
The main goal is to use maps with defaults for the handler-specific options of all HTTP handlers in the
listen
section.Because the rework is significant, it turned out that it makes sense to simplify the configuration of
mongoose_client_api
, which was way too complicated for the end user (and some options were giving the illusion of being configurable, while only the initial values worked, e.g. Swagger path). Now all handlers are enabled by default and the user can set a custom list (withhandlers = [...]
) or disable the Swagger docs (withdocs = false
). For simplicity and consistency, all handlers are also enabled by default formongoose_api
.A new behaviour,
mongoose_http_handler
, is introduced. Its introduction improved the separation between the listener implementation (ejabberd_cowboy
) and the API module for managing handlers. There are two optional callbacks:config_spec/0
returning config specification for the handler, if it has any optionsroutes/1
returning Cowboy routes, if different from the defaultExcluded from this PR:
mod_bosh
does not implement the new behaviour because of a callback name clash forconfig_spec
. If it requires any options or more complex routes, we could implement a new module with these functions. This would separate module-specific logic from handler-specific logic.mongoose_api_client
is very confusing as there ismongoose_client_api
as well. The former is obsolete, undocumented, but apparently still offers some unique functionality (e.g.change_password
,subscription
). It needs to be fully replaced by the latter, but this is out of scope for now. I think we could sort this out soon as a part of our ongoing API rework.