FWRouter 0.1.0

FWRouter 0.1.0

Maintained by JianweiWangs.



FWRouter 0.1.0

  • By
  • JianweiWangs

FWRouter

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.