Skip to content

Latest commit

 

History

History
107 lines (76 loc) · 2.63 KB

README.md

File metadata and controls

107 lines (76 loc) · 2.63 KB

FWRouter

Contact Us CI Status Version License Platform codecov

中文版本请查看这里

FWRouter is a High-performance trie-node router, idea from Vapor/routing

This is not a Server router, but an iOS UI Router, You can build your own iOS app from it.

Example

use

git clone https://github.com/JianweiWangs/FWRouter.git
cd FWRouter
make

to fetch and build source code quickly.

There are also some script help you develop and PR.

# install dependence and open project
make

# install dependence
make install

# build test
make test

# open project
make open

# quit Xcode
make quit

Before you pull request, make sure test success.

Usage

URL Match

let router = FWRouterManager.shared.router
// url match
route.match("scheme://host/path") { (target) -> Bool in
    let demoVC = DemoViewController()
    target.navigation?.pushViewController(demoVC, animated: true)
    return true
}
route.route(url: "scheme://host/path")

Path Parameter

router.match("scheme://host", "parameter", String.parameter, use: { (target) -> Bool in
    print(target.url) // scheme://host/parameter/param0
    print(target.pathParamters.next(String.self)) // "param0"
    return true
})
router.route(url: "scheme://host/parameter/param0")

Parameter

router.match("scheme://host/path", "/thridParameter", use: { (target) -> Bool in
    print(target.parameters["name"] as? String) //"wangjianwei"
    return true
})
router.route(
    url: "scheme://host/path/thridParameter", 
    parameters: ["name": "wangjianwei"]
)

Requirements

This library requires iOS 8.0+, Xcode 9.0+ and Swift 4.0+.

Installation

FWRouter is available through CocoaPods. To install it, simply add the following line to your Podfile:

pod 'FWRouter'

Author

JianweiWangs, [email protected]

License

FWRouter is available under the MIT license. See the LICENSE file for more info.