Latest 0.2.1
Homepage https://github.com/woxtu/RouteKit
License MIT
Platforms ios 9.0, osx 10.12
Authors

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.2

CocoaPods

pod 'RouteKit', '~> 0.2'

Swift Package Manager

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

License

Licensed under the MIT license.

Latest podspec

{
    "name": "RouteKit",
    "version": "0.2.1",
    "license": {
        "type": "MIT",
        "file": "LICENSE-MIT"
    },
    "homepage": "https://github.com/woxtu/RouteKit",
    "authors": {
        "woxtu": "[email protected]"
    },
    "summary": "Type-safe URL routing for Swift.",
    "source": {
        "git": "https://github.com/woxtu/RouteKit.git",
        "tag": "0.2.1"
    },
    "platforms": {
        "ios": "9.0",
        "osx": "10.12"
    },
    "source_files": "Sources/**/*.swift",
    "ios": {
        "frameworks": "UIKit"
    }
}

Pin It on Pinterest

Share This