From a6a9022d8ee337e8ba50e1c1bddc4142e62c1fe1 Mon Sep 17 00:00:00 2001 From: Valerio Date: Thu, 2 May 2024 11:51:06 +0200 Subject: [PATCH] apply allowMiddlewares --- Source/Core/ApiClient+Closure.swift | 28 ++++++++++++++++------------ 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/Source/Core/ApiClient+Closure.swift b/Source/Core/ApiClient+Closure.swift index f35b41f..9082f4f 100644 --- a/Source/Core/ApiClient+Closure.swift +++ b/Source/Core/ApiClient+Closure.swift @@ -194,18 +194,20 @@ extension ApiClient { } } - do { - try applyPreRequestMiddlewares(request: request) - } catch { - completion( - Response( - result: .failure(.middleware(error)), - session: session, - request: request, - response: nil + if endpoint.allowMiddlewares { + do { + try applyPreRequestMiddlewares(request: request) + } catch { + completion( + Response( + result: .failure(.middleware(error)), + session: session, + request: request, + response: nil + ) ) - ) - return nil + return nil + } } progressHUD?.show() @@ -307,7 +309,9 @@ extension ApiClient { } // Run postResponse Middlewares - if let url = request.url, !middlewares.isEmpty { + if endpoint.allowMiddlewares, + let url = request.url, + !middlewares.isEmpty { do { let pathComponents = url.pathComponents