CocoaPods trunk is moving to be read-only. Read more on the blog, there are 14 months to go.
| TestsTested | ✓ |
| LangLanguage | SwiftSwift |
| License | Apache 2 |
| ReleasedLast Release | Oct 2015 |
| SPMSupports SPM | ✗ |
Maintained by Aaron Harmon, Martino Buffolino.
A micro routing library written in swift, primarily for deep linking use cases
Embedded frameworks require a minimum deployment target of iOS 8.
Integration can be done either Manually or through Cocoapods
import Router
// create your router
let router = Router()
// bind your routes with a callback
router.bind("/route/:id") { (req) -> Void in
print(req.param("id")!)
}
// match a route
let url = NSURL(string: "routerapp://route/abc123")!
let route = router.match(url)Bind a closure to a route definition
router.bind("/route/:id") { (req) -> Void in
print(req.param("id")!)
}Matches an incoming url to a route in the Router. If a match is made, the closure is executed and the matched route is returned
let url = NSURL(string: "routerapp://route/abc123")!
let route = router.match(url)A request object is accessible in the closure arg. Access url params in the closure (ie. id from /route/:id) by using .param() function
router.bind("/route/:id") { (req) -> Void in
let id = req.param("id")!
}Access query string params from the callback (ie. /route/123?foo=bar) by using .query() function
router.bind("/route/:id") { (req) -> Void in
let foo = req.query("foo")!
}Licensed under the Apache License, Version 2.0. See LICENSE for details.