Library to simplify network routing management
import Foundation
import ApiRouter
internal enum WordRouter {
case words(query: Encodable)
case wordMeaning(query: Encodable)
}
// MARK: - Implement AbstractRouter
extension WordRouter: AbstractRouter {
var path: String {
switch self {
case .words:
return publicV1 + "/words/search"
case .wordMeaning:
return publicV1 + "/meanings"
}
}
var method: HTTPMethod {
.get
}
var queryParameters: Encodable? {
switch self {
case .wordMeaning(let query), .words(let query):
return query
}
}
var body: Encodable? {
nil
}
}
let request = try route.convertToURLRequest(with: JSONEncoder())
let url = try route.convertToURL(with: JSONEncoder())
# Podfile
use_frameworks!
target 'YOUR_TARGET_NAME' do
pod 'ApiRouter'
end
Replace YOUR_TARGET_NAME
and then, in the Podfile
directory, type:
$ pod install
Eugene Rudakov - linkedin