Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Alamofire 5]: AlamofireExtended extension point. #2758

Merged
merged 1 commit into from
Mar 27, 2019
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 11 additions & 1 deletion Alamofire.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,10 @@
31D83FCF20D5C29300D93E47 /* URLConvertible+URLRequestConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31D83FCD20D5C29300D93E47 /* URLConvertible+URLRequestConvertible.swift */; };
31D83FD020D5C29300D93E47 /* URLConvertible+URLRequestConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31D83FCD20D5C29300D93E47 /* URLConvertible+URLRequestConvertible.swift */; };
31D83FD120D5C29300D93E47 /* URLConvertible+URLRequestConvertible.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31D83FCD20D5C29300D93E47 /* URLConvertible+URLRequestConvertible.swift */; };
31DADDFB224811ED0051390F /* AlamofireExtended.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31DADDFA224811ED0051390F /* AlamofireExtended.swift */; };
31DADDFC224811ED0051390F /* AlamofireExtended.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31DADDFA224811ED0051390F /* AlamofireExtended.swift */; };
31DADDFD224811ED0051390F /* AlamofireExtended.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31DADDFA224811ED0051390F /* AlamofireExtended.swift */; };
31DADDFE224811ED0051390F /* AlamofireExtended.swift in Sources */ = {isa = PBXBuildFile; fileRef = 31DADDFA224811ED0051390F /* AlamofireExtended.swift */; };
31EBD9C120D1D89C00D1FF34 /* ValidationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8AE910119D28DCC0078C7B2 /* ValidationTests.swift */; };
31EBD9C220D1D89C00D1FF34 /* ValidationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8AE910119D28DCC0078C7B2 /* ValidationTests.swift */; };
31EBD9C320D1D89D00D1FF34 /* ValidationTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = F8AE910119D28DCC0078C7B2 /* ValidationTests.swift */; };
Expand Down Expand Up @@ -380,6 +384,7 @@
31B2CA9421AA24F5005B371A /* Package@swift-4.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "Package@swift-4.swift"; sourceTree = "<group>"; };
31B2CA9521AA25CD005B371A /* Package.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = Package.swift; sourceTree = "<group>"; };
31D83FCD20D5C29300D93E47 /* URLConvertible+URLRequestConvertible.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLConvertible+URLRequestConvertible.swift"; sourceTree = "<group>"; };
31DADDFA224811ED0051390F /* AlamofireExtended.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AlamofireExtended.swift; sourceTree = "<group>"; };
31ED52E61D73889D00199085 /* AFError+AlamofireTests.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = "AFError+AlamofireTests.swift"; sourceTree = "<group>"; };
31F5085C20B50DC400FE2A0C /* URLSessionConfiguration+Alamofire.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = "URLSessionConfiguration+Alamofire.swift"; sourceTree = "<group>"; };
31F9683B20BB70290009606F /* NSLoggingEventMonitor.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = NSLoggingEventMonitor.swift; sourceTree = "<group>"; };
Expand Down Expand Up @@ -708,8 +713,8 @@
319917A9209CDCB000103A19 /* HTTPHeaders.swift */,
31727417218BAEC90039FFCC /* HTTPMethod.swift */,
4CB928281C66BFBC00CE5F08 /* Notifications.swift */,
4CE2724E1AF88FB500F1D59A /* ParameterEncoding.swift */,
3172741C218BB1790039FFCC /* ParameterEncoder.swift */,
4CE2724E1AF88FB500F1D59A /* ParameterEncoding.swift */,
3191B5741F5F53A6003960A8 /* Protector.swift */,
31991790209CDA7F00103A19 /* Request.swift */,
319917A4209CDAC400103A19 /* RequestTaskMap.swift */,
Expand All @@ -725,6 +730,7 @@
4CDE2C491AF8A14E00BABAE5 /* Features */ = {
isa = PBXGroup;
children = (
31DADDFA224811ED0051390F /* AlamofireExtended.swift */,
4C4466EA21F8F5D800AC9703 /* CachedResponseHandler.swift */,
3111CE8720A77843008315E2 /* EventMonitor.swift */,
4C23EB421B327C5B0090E0BC /* MultipartFormData.swift */,
Expand Down Expand Up @@ -1338,6 +1344,7 @@
3199179E209CDA7F00103A19 /* Session.swift in Sources */,
4CF627071BA7CBF60011A099 /* Alamofire.swift in Sources */,
3111CE8A20A77945008315E2 /* EventMonitor.swift in Sources */,
31DADDFD224811ED0051390F /* AlamofireExtended.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1409,6 +1416,7 @@
3199179D209CDA7F00103A19 /* Session.swift in Sources */,
4C0E5BF91B673D3400816CCC /* Result.swift in Sources */,
3111CE8920A77944008315E2 /* EventMonitor.swift in Sources */,
31DADDFC224811ED0051390F /* AlamofireExtended.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1446,6 +1454,7 @@
3199179F209CDA7F00103A19 /* Session.swift in Sources */,
E4202FD81B667AA100C997FB /* Validation.swift in Sources */,
3111CE8B20A77945008315E2 /* EventMonitor.swift in Sources */,
31DADDFE224811ED0051390F /* AlamofireExtended.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down Expand Up @@ -1483,6 +1492,7 @@
3199179C209CDA7F00103A19 /* Session.swift in Sources */,
4C0E5BF81B673D3400816CCC /* Result.swift in Sources */,
3111CE8820A77843008315E2 /* EventMonitor.swift in Sources */,
31DADDFB224811ED0051390F /* AlamofireExtended.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
};
Expand Down
55 changes: 55 additions & 0 deletions Source/AlamofireExtended.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,55 @@
//
// AlamofireExtended.swift
//
// Copyright (c) 2019 Alamofire Software Foundation (http://alamofire.org/)
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
// to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
// copies of the Software, and to permit persons to whom the Software is
// furnished to do so, subject to the following conditions:
//
// The above copyright notice and this permission notice shall be included in
// all copies or substantial portions of the Software.
//
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
// THE SOFTWARE.
//

/// Type that acts as a generic extension point for all `AlamofireExtended` types.
public struct AlamofireExtension<ExtendedType> {
/// Stores the type or metatype of any extended type.
let type: ExtendedType

init(_ type: ExtendedType) {
self.type = type
}
}

/// Protocol describing the `af` extension points for Alamofire extended types.
public protocol AlamofireExtended {
associatedtype ExtendedType

/// Static Alamofire extension point.
static var af: AlamofireExtension<ExtendedType>.Type { get set }
/// Instance Alamofire extension point.
var af: AlamofireExtension<ExtendedType> { get set }
cnoon marked this conversation as resolved.
Show resolved Hide resolved
}

public extension AlamofireExtended {
static var af: AlamofireExtension<Self>.Type {
get { return AlamofireExtension<Self>.self }
set { }
}

var af: AlamofireExtension<Self> {
get { return AlamofireExtension(self) }
set { }
cnoon marked this conversation as resolved.
Show resolved Hide resolved
}
}
Loading