All Projects → chenxiancai → STCRouter

chenxiancai / STCRouter

Licence: MIT license
基于标准URL的iOS路由系统,可实现业务模块组件化,控制器之间零耦合,可实现黑白名单控制,可进行native降级到hybrid。

Programming Languages

objective c
16641 projects - #2 most used programming language
ruby
36898 projects - #4 most used programming language

Projects that are alternatives of or similar to STCRouter

router
Bidirectional Ring router. REST oriented. Rails inspired.
Stars: ✭ 78 (+310.53%)
Mutual labels:  router, routes, routing
Next Routes
Universal dynamic routes for Next.js
Stars: ✭ 2,354 (+12289.47%)
Mutual labels:  router, routes, routing
Router
Router implementation for fasthttp
Stars: ✭ 234 (+1131.58%)
Mutual labels:  router, routing, routing-engine
routex.js
🔼 Alternative library to manage dynamic routes in Next.js
Stars: ✭ 38 (+100%)
Mutual labels:  router, routes, routing
Simple Php Router
Simple, fast and yet powerful PHP router that is easy to get integrated and in any project. Heavily inspired by the way Laravel handles routing, with both simplicity and expand-ability in mind.
Stars: ✭ 279 (+1368.42%)
Mutual labels:  router, routing, routing-engine
gatsby-plugin-dynamic-routes
Creating dynamic routes based on your environment and/or renaming existing routes
Stars: ✭ 14 (-26.32%)
Mutual labels:  router, routes, routing
vue-error-page
[NO LONGER MAINTAINED] Provides a wrapper for router-view that allows you to show error pages without changing the URL.
Stars: ✭ 52 (+173.68%)
Mutual labels:  routes, routing, route
Ffrouter
Powerful and easy-to-use URL routing library in iOS that supports URL Rewrite(强大、易用、支持 URL Rewrite的 iOS 路由库)
Stars: ✭ 263 (+1284.21%)
Mutual labels:  router, routing, routing-engine
Freerouting
Advanced PCB autorouter (finally, no Java installation required)
Stars: ✭ 307 (+1515.79%)
Mutual labels:  router, routing, routing-engine
Universal Router
A simple middleware-style router for isomorphic JavaScript web apps
Stars: ✭ 1,598 (+8310.53%)
Mutual labels:  router, routes, routing
Klein.php
A fast & flexible router
Stars: ✭ 2,622 (+13700%)
Mutual labels:  router, routing
Falco
A functional-first toolkit for building brilliant ASP.NET Core applications using F#.
Stars: ✭ 214 (+1026.32%)
Mutual labels:  router, routing
Swiftuirouter
Routing in SwiftUI
Stars: ✭ 242 (+1173.68%)
Mutual labels:  router, routing
Clevergo
👅 CleverGo is a lightweight, feature rich and high performance HTTP router for Go.
Stars: ✭ 246 (+1194.74%)
Mutual labels:  router, routing
Ui Router
The de-facto solution to flexible routing with nested views in AngularJS
Stars: ✭ 13,738 (+72205.26%)
Mutual labels:  router, routing
path-to-regexp-php
PHP port of https://github.com/pillarjs/path-to-regexp
Stars: ✭ 21 (+10.53%)
Mutual labels:  routing, route
RouteNow
RouteNow is a small fast library ⚡ that will help you in developing a SinglePage Application without any dependencies like jQuery, AngularJs, vue.js or any of those bulky frameworks.
Stars: ✭ 17 (-10.53%)
Mutual labels:  router, routing
node-match-path
Matches a URL against a path. Parameters, wildcards, RegExp.
Stars: ✭ 30 (+57.89%)
Mutual labels:  routing, route
url-trailing-slash
Allows enforcing URL routes with or without trailing slash
Stars: ✭ 35 (+84.21%)
Mutual labels:  routing, route
FGRoute
Get your device ip address, router ip or wifi ssid
Stars: ✭ 128 (+573.68%)
Mutual labels:  router, route

STCRouter

how to use

pod 'STCRouter'

standard URL format

http:\\host[:port][abs_path][:parameters][?query]#fragment

example

1.Use STCRouterCenter to register URL format for controller with params, like this:

[[STCRouterCenter defaultCenter].router  registerURLFormat:@"router:///root" 
toController:[ModalController class] withOptions:[[[STCRouterOption routerOptions] rootIndex:0] 
forDefaultParams:@{@"title": @"root"}]];

2.Setup blackList or whiteList, like this:

// 设置路由黑名单
[[STCRouterCenter defaultCenter] addBlackListWithObjects:@[@"com.apple.mobilesafari"]];

// 设置路由白名单
[[STCRouterCenter defaultCenter] addWhiteListInPathWithBIDs:@{@"root": @[@""]}];
[[STCRouterCenter defaultCenter] addWhiteListInPathWithBIDs:@{@"child": @[@"com.stevchen.STCRouter"]}];

Attention:
so, if you add a bundleId into blackList, app with this bundleId cann't open any path in router.
If you add route path with bundleId into whiteList, only app with bundleId in whiteList can open the route.

3.handle undefinded route, like this: 

[[STCRouterCenter defaultCenter].router setRouterForward:^(STCRouterParams *routerParams, STCRouterError *error) {
      //handle undefinded route
}];
 
4.open route, like this:

inside app without scheme

[[STCRouterCenter defaultCenter].router openURL:@"/child/user/child/user" withAnimated:YES extraParams:nil];

or outside app with scheme

[[STCRouterCenter defaultCenter].router openExternalURL:@"router:///root"];

or with stack controllers

[[STCRouterCenter defaultCenter].router openURL:@"router:///user/child/root"];

5.intercept route, like this:

 NSString *sourceApplication = [options valueForKey:UIApplicationOpenURLOptionsSourceApplicationKey];
 BOOL isFilter = [[STCRouterCenter defaultCenter] filterRouterWithUrl:url.absoluteString BID:sourceApplication];
 if (!isFilter) {
        [[STCRouterCenter defaultCenter].router openURL:url.absoluteString withAnimated:YES extraParams:nil];
 }
 
 6.set route from native to hybird, like this:
 
 [[STCRouterCenter defaultCenter].router changeURLFormat:@"router:///child" toHybridUrl:@"http://www.baidu.com"];
  
 you can revert it to native route:
 
 [[STCRouterCenter defaultCenter].router revertFromHybridWithURLFormat:@"router:///child"];

Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].