RouterCenter.default.register(url: "https://m.baidu.com", handlerClass: ClassRouterHandler.self)
RouterCenter.default.register(url: "https://m.init.com", handlerObject: handler)
RouterCenter.default.register(url: "https://testvc", viewController: TestRouterViewController.self)
struct ObjectRouterHandler : RouterHandlerProtocol{
func handleRouter(url: String, parameters: [String : Any]?, completion: ((RouterResponseProtocol) -> Void)?) {
completion?(RouterResponse(data: "ObjectRouterHandler-success"))
}
}
struct ClassRouterHandler : RouterStaticHandlerProtocol {
static func handleRouter(url: String, parameters: [String : Any]?, completion: ((RouterResponseProtocol) -> Void)?) {
completion?(RouterResponse(data: "ClassRouterHandler-success"))
}
}
To run the example project, clone the repo, and run pod install
from the Example directory first.
AnyRouter is available through CocoaPods. To install it, simply add the following line to your Podfile:
pod 'AnyRouter'
hsh, qinyue0306@163.com
AnyRouter is available under the MIT license. See the LICENSE file for more info.