From 726b2800640467ceb5d32ee49434aa2ed81f1fc0 Mon Sep 17 00:00:00 2001 From: Valerio Date: Thu, 2 May 2024 11:47:09 +0200 Subject: [PATCH] add allowMiddlewares property to Requestable --- Source/Endpoint/DownloadEndpoint.swift | 5 ++++- Source/Endpoint/Endpoint.swift | 5 ++++- Source/Endpoint/MultipartFormEndpoint.swift | 4 ++++ Source/Endpoint/Protocol/Requestable.swift | 3 +++ 4 files changed, 15 insertions(+), 2 deletions(-) diff --git a/Source/Endpoint/DownloadEndpoint.swift b/Source/Endpoint/DownloadEndpoint.swift index 52b7eda..ffe5028 100644 --- a/Source/Endpoint/DownloadEndpoint.swift +++ b/Source/Endpoint/DownloadEndpoint.swift @@ -35,6 +35,7 @@ public struct DownloadEndpoint: Requestable { public var queryParameters: QueryParameters? public let body: HTTPBody? = nil public let form: MultipartFormData? = nil + public var allowMiddlewares: Bool public init( path: String, @@ -42,7 +43,8 @@ public struct DownloadEndpoint: Requestable { method: HTTPMethod = .get, headers: [String: String] = [:], useEndpointHeaderOnly: Bool = false, - queryParameters: QueryParameters? = nil + queryParameters: QueryParameters? = nil, + allowMiddlewares: Bool = true ) { self.path = path self.isFullPath = isFullPath @@ -50,5 +52,6 @@ public struct DownloadEndpoint: Requestable { self.headers = headers self.useEndpointHeaderOnly = useEndpointHeaderOnly self.queryParameters = queryParameters + self.allowMiddlewares = allowMiddlewares } } diff --git a/Source/Endpoint/Endpoint.swift b/Source/Endpoint/Endpoint.swift index 44b8bee..3c01a45 100644 --- a/Source/Endpoint/Endpoint.swift +++ b/Source/Endpoint/Endpoint.swift @@ -36,6 +36,7 @@ public struct Endpoint: Requestable { public var queryParameters: QueryParameters? public var body: HTTPBody? public let form: MultipartFormData? = nil + public var allowMiddlewares: Bool public init( path: String, @@ -44,7 +45,8 @@ public struct Endpoint: Requestable { headers: [String: String] = [:], useEndpointHeaderOnly: Bool = false, queryParameters: QueryParameters? = nil, - body: HTTPBody? = nil + body: HTTPBody? = nil, + allowMiddlewares: Bool = true ) { self.path = path self.isFullPath = isFullPath @@ -53,5 +55,6 @@ public struct Endpoint: Requestable { self.useEndpointHeaderOnly = useEndpointHeaderOnly self.queryParameters = queryParameters self.body = body + self.allowMiddlewares = allowMiddlewares } } diff --git a/Source/Endpoint/MultipartFormEndpoint.swift b/Source/Endpoint/MultipartFormEndpoint.swift index 9d9881c..7c0ec50 100644 --- a/Source/Endpoint/MultipartFormEndpoint.swift +++ b/Source/Endpoint/MultipartFormEndpoint.swift @@ -34,8 +34,10 @@ public struct MultipartFormEndpoint: Requestable { public var useEndpointHeaderOnly: Bool public var queryParameters: QueryParameters? public let body: HTTPBody? = nil + public var allowMiddlewares: Bool public var form: MultipartFormData? + public init( path: String, isFullPath: Bool = false, @@ -43,6 +45,7 @@ public struct MultipartFormEndpoint: Requestable { headers: [String: String] = [:], useEndpointHeaderOnly: Bool = false, queryParameters: QueryParameters? = nil, + allowMiddlewares: Bool = true, form: MultipartFormData ) { self.path = path @@ -51,6 +54,7 @@ public struct MultipartFormEndpoint: Requestable { self.headers = headers self.useEndpointHeaderOnly = useEndpointHeaderOnly self.queryParameters = queryParameters + self.allowMiddlewares = allowMiddlewares self.form = form } } diff --git a/Source/Endpoint/Protocol/Requestable.swift b/Source/Endpoint/Protocol/Requestable.swift index a102895..9caa86b 100644 --- a/Source/Endpoint/Protocol/Requestable.swift +++ b/Source/Endpoint/Protocol/Requestable.swift @@ -73,6 +73,9 @@ public protocol Requestable { /// Multipart Form Data Form var form: MultipartFormData? { get } + /// Call + var allowMiddlewares: Bool { get } + /// Return the `URLRequest` from the Requestable func urlRequest(with config: NetworkConfigurable) throws -> URLRequest }