Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/yume190/entryable
https://github.com/yume190/entryable
Last synced: 11 days ago
JSON representation
- Host: GitHub
- URL: https://github.com/yume190/entryable
- Owner: yume190
- License: mit
- Created: 2017-12-27T08:03:14.000Z (about 7 years ago)
- Default Branch: master
- Last Pushed: 2023-04-20T03:51:21.000Z (over 1 year ago)
- Last Synced: 2024-12-30T22:41:54.187Z (18 days ago)
- Language: Swift
- Size: 105 KB
- Stars: 0
- Watchers: 1
- Forks: 1
- Open Issues: 0
-
Metadata Files:
- Readme: README.MD
- License: LICENSE
Awesome Lists containing this project
README
# 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
```swift
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]
}
}
}
```