Go to file
Yume edc009e0f3 add new config 2023-04-20 11:51:03 +08:00
.swiftpm/xcode/package.xcworkspace remove xcode project 2021-11-15 13:26:07 +08:00
Sources add new config 2023-04-20 11:51:03 +08:00
Tests/EntryableTests rename `Response` to `HTTPRawResponse` 2021-11-29 13:37:19 +08:00
.gitignore to swift 5 2019-06-21 15:40:22 +08:00
.swiftlint.yml add swift lint 2018-12-17 15:47:52 +08:00
.travis.yml carthage build to update 2019-01-18 14:25:05 +08:00
Cartfile remove await 2019-07-04 17:34:45 +08:00
Cartfile.private add travis CI 2018-12-11 15:32:15 +08:00
Cartfile.resolved Fix carthage Setting 2019-10-05 15:58:36 +08:00
LICENSE 調整 for pod 2018-05-29 17:14:46 +08:00
Makefile fix phony 2019-03-27 11:51:19 +08:00
Package.resolved add error for trace url, origin data, origin error 2022-03-17 15:50:19 +08:00
Package.swift Entry add reponseData parameter 2022-07-14 15:19:22 +08:00
README.MD update readme 2021-11-15 14:29:08 +08:00
YumeAlamofire.podspec Fix carthage Setting 2019-10-05 15:58:36 +08:00

README.MD

Entryable


SPM

.package(url: "https://github.com/yume190/Entryable.git", from: "5.1.0")

Pod

pod 'YumeAlamofire', :git => 'https://github.com/yume190/Entryable.git', :tag => '5.1.0'


Example

struct Entry {
    static let base = "http://127.0.0.1:3000"
    
    public static let session: Session = {
        let configuration = URLSessionConfiguration.default
        configuration.timeoutIntervalForRequest = 15 // seconds
        configuration.timeoutIntervalForResource = 15
        configuration.urlCache = nil
        return Session(configuration: configuration, requestQueue: DispatchQueue.global(qos: .background))
//        return Session(configuration: configuration)
    }()
}

extension Entry {
    struct A: EncodeEntryable {
        typealias ResponseType = Response
        
        public struct Parameters: Encodable {
            let a: String
        }
        
        let key: String
        
        let url: URLConvertible = Entry.base + "/yume"
        let session: Session = Entry.session
        let method: Alamofire.HTTPMethod = .get
        let parameters: Parameters? = Parameters(a: "b")
        let parameterType: ParameterType = .url
        var headers: Headers {
            return ["key" : key]
        }
    }
}

extension Entry.A {
    public struct Response: Codable, Equatable {
        let code: Int
        let message: String
    }
}

extension Entry {
    struct B: DictionaryEntryable {
        typealias ResponseType = Void
        
        let key: String
        init(key: String) {
            self.key = key
        }
        
        let url: URLConvertible = Entry.base + "/yume"
        let session: Session = Entry.session
        let method: Alamofire.HTTPMethod = .head
        let parameters: Parameters? = [:]
        var headers: Headers {
            return ["key" : key]
        }
    }
}