dexter has submitted this change. (
https://gerrit.osmocom.org/c/onomondo-eim/+/43087?usp=email )
(
6 is the latest approved patch-set.
No files were changed between the latest approved patch-set and the submitted
one.
)Change subject: onomondo_eim_app: unify HTTP/HTTPs server startup
......................................................................
onomondo_eim_app: unify HTTP/HTTPs server startup
The REST API also makes use of the cowboy HTTP server in the same
way as the ESipa API does when running without SSL/TLS. Let's unify
the code in such a way that both HTTP servers call the same startup
helper functions.
Related: SYS#8100
Change-Id: Ie63a97b7ca6873d02866a11226733b37017504cd
---
M src/onomondo_eim_app.erl
1 file changed, 19 insertions(+), 16 deletions(-)
Approvals:
jolly: Looks good to me, but someone else must approve
laforge: Looks good to me, approved
dexter: Looks good to me, but someone else must approve
Jenkins Builder: Verified
diff --git a/src/onomondo_eim_app.erl b/src/onomondo_eim_app.erl
index 97ed197..20d07a5 100644
--- a/src/onomondo_eim_app.erl
+++ b/src/onomondo_eim_app.erl
@@ -10,8 +10,8 @@
-export([start/2, esipa_dispatch/0]).
-export([stop/1]).
-start_esipa_server(true, Ip, Port, _Cert, _Key, Dispatch) ->
- logger:notice("Starting ESipa HTTP server at ~p:~p...~n", [Ip, Port]),
+start_esipa_server(true, Ip, Port, _Cert, _Key, Dispatch, Middlewares,
InterfaceName) ->
+ logger:notice("Starting ~s HTTP server at ~p:~p...~n", [InterfaceName, Ip,
Port]),
cowboy:start_clear(
http_listener_esipa,
[
@@ -22,13 +22,13 @@
env => #{
dispatch => Dispatch
},
- middlewares => [cowboy_router, esipa_middleware, cowboy_handler]
+ middlewares => Middlewares
}
);
-start_esipa_server(false, Ip, Port, Cert, Key, Dispatch) ->
+start_esipa_server(false, Ip, Port, Cert, Key, Dispatch, Middlewares,
InterfaceName) ->
logger:notice(
- "Starting ESipa HTTPs server at ~p:~p...~ncertificate: ~p~nkey: ~p~n",
- [Ip, Port, Cert, Key]
+ "Starting ~s HTTPs server at ~p:~p...~ncertificate: ~p~nkey: ~p~n",
+ [InterfaceName, Ip, Port, Cert, Key]
),
cowboy:start_tls(
@@ -43,7 +43,7 @@
env => #{
dispatch => Dispatch
},
- middlewares => [cowboy_router, esipa_middleware, cowboy_handler]
+ middlewares => Middlewares
}
).
@@ -113,21 +113,24 @@
EsipaPort,
EsipaSslCert,
EsipaSslKey,
- Dispatch_ESipa
+ Dispatch_ESipa,
+ [cowboy_router, esipa_middleware, cowboy_handler],
+ "ESipa"
),
% Startup REST server
Dispatch_REST = rest_dispatch(),
{ok, RestIp} = application:get_env(onomondo_eim, rest_ip),
{ok, RestPort} = application:get_env(onomondo_eim, rest_port),
- logger:notice("Starting REST HTTP server at ~p:~p...~n", [RestIp,
RestPort]),
- {ok, _} = cowboy:start_clear(
- http_listener_rest,
- [
- {ip, RestIp},
- {port, RestPort}
- ],
- #{env => #{dispatch => Dispatch_REST}}
+ {ok, _} = start_esipa_server(
+ true,
+ RestIp,
+ RestPort,
+ none,
+ none,
+ Dispatch_REST,
+ [cowboy_router, cowboy_handler],
+ "REST"
),
onomondo_eim_sup:start_link().
--
To view, visit https://gerrit.osmocom.org/c/onomondo-eim/+/43087?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.osmocom.org/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: onomondo-eim
Gerrit-Branch: master
Gerrit-Change-Id: Ie63a97b7ca6873d02866a11226733b37017504cd
Gerrit-Change-Number: 43087
Gerrit-PatchSet: 7
Gerrit-Owner: dexter <[email protected]>
Gerrit-Reviewer: Jenkins Builder
Gerrit-Reviewer: dexter <[email protected]>
Gerrit-Reviewer: jolly <[email protected]>
Gerrit-Reviewer: laforge <[email protected]>