Go to file
woxtu eda807ff4b Add badges 2018-03-17 17:48:14 +09:00
RouteKit.xcodeproj Add Carthage support 2018-03-16 03:21:06 +09:00
Sources/RouteKit Make initializer public 2018-03-16 03:16:12 +09:00
Tests/RouteKitTests Add Router 2018-03-14 01:51:27 +09:00
.gitignore Initial commit 2018-03-02 02:30:49 +09:00
.swift-version Add Swift Package Manager support 2018-03-15 02:10:52 +09:00
LICENSE-MIT Add LICENSE 2018-03-15 01:43:44 +09:00
Package.swift Add Swift Package Manager support 2018-03-15 02:10:52 +09:00
README.md Add badges 2018-03-17 17:48:14 +09:00
RouteKit.podspec Add CocoaPods support 2018-03-16 03:25:40 +09:00

README.md

RouteKit

Carthage compatible CocoaPods Swift Package Manager

Type-safe URL routing for Swift.

// Define routes
struct UserIndex : Route {
    let path = "/users"

    func map(to url: URL, parameters: [String : String], queries: [String : String]) -> UIViewController {
        return UserIndexViewController()
    }
}

struct UserDetail : Route {
    let path = "/users/{id}"

    struct Parameters : Decodable {
        let id: Int
    }

    func map(to url: URL, parameters: Parameters, queries: [String : String]) -> UIViewController {
        return UserDetailViewController(id: parameters.id)
    }
}

// Use `Navigator` (for iOS)
Navigator.append(route: UserIndex())
Navigator.append(route: UserDetail())

Navigator.push(url: URL(string: "/users/42")!, animated: true)
Navigator.present(url: URL(string: "/users/42")!, animated: true)

// Use `Router`
let router = Router<UIViewController>()
router.append(route: UserIndex())
router.append(route: UserDetail())

router.push(url: URL(string: "/users/42")!) // Return `UserDetailViewController`

Greatly inspired by ishkawa/APIKit, devxoul/URLNavigator.

Installation

Carthage

github "woxtu/RouteKit" ~> 0.1

CocoaPods

pod 'RouteKit', '~> 0.1'

Swift Package Manager

.package(url: "https://github.com/woxtu/RouteKit.git", from: "0.1.0")

License

Licensed under the MIT license.