Skip to content

Instantly share code, notes, and snippets.

@michzio
Created December 12, 2021 13:31
Show Gist options
  • Save michzio/305756d8cf1e9aa3340615e477a7d3e8 to your computer and use it in GitHub Desktop.
Save michzio/305756d8cf1e9aa3340615e477a7d3e8 to your computer and use it in GitHub Desktop.
SwiftUI MVVM architecture - Router
enum WordsetRouter: Router {
case getWordsets
case getWordset(id: String)
static var baseURL: String = "https://mockapi.com"
var path: String {
switch self {
case .getWordsets:
return "/wordsets"
case let .getWordset(id):
return "/wordsets/\(id)"
}
}
var method: HTTPMethod {
switch self {
case .getWordsets, .getWordset:
return .get
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment