]> granicus.if.org Git - ejabberd/commitdiff
Raise api hook right before performing the call
authorChristophe Romain <christophe.romain@process-one.net>
Tue, 7 May 2019 09:46:04 +0000 (11:46 +0200)
committerChristophe Romain <christophe.romain@process-one.net>
Tue, 7 May 2019 09:46:04 +0000 (11:46 +0200)
src/rest.erl

index 05d1b9d4a9ae54d36193bfc39b3c4e20febfc6ff..9c1b28068a32bcade8e3ee10d66b4cd6e0f40d28 100644 (file)
@@ -100,6 +100,7 @@ request(Server, Method, Path, Params, Mime, Data) ->
                   {URI, Hdrs}
           end,
     Begin = os:timestamp(),
+    ejabberd_hooks:run(backend_api_call, Server, [Server, Method, Path]),
     Result = try httpc:request(Method, Req, HttpOpts, [{body_format, binary}]) of
         {ok, {{_, Code, _}, RetHdrs, Body}} ->
             try decode_json(Body) of
@@ -118,7 +119,6 @@ request(Server, Method, Path, Params, Mime, Data) ->
         exit:Reason ->
             {error, {http_error, {error, Reason}}}
     end,
-    ejabberd_hooks:run(backend_api_call, Server, [Server, Method, Path]),
     case Result of
         {error, {http_error, {error, timeout}}} ->
             ejabberd_hooks:run(backend_api_timeout, Server,