Skip to content

Commit

Permalink
apply allowMiddlewares
Browse files Browse the repository at this point in the history
  • Loading branch information
vetrek committed May 2, 2024
1 parent c012395 commit a6a9022
Showing 1 changed file with 16 additions and 12 deletions.
28 changes: 16 additions & 12 deletions Source/Core/ApiClient+Closure.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit a6a9022

Please sign in to comment.