Comments (6)
你希望包含哪些异常信息,颗粒度是怎么样的,这个功能可以帮助你解决业务上的什么问题呢?
from drouter.
你希望包含哪些异常信息,颗粒度是怎么样的,这个功能可以帮助你解决业务上的什么问题呢?
比如打开一本书时,第一层拦截是检查登录,第二层拦截是检查是否已付费购买,第二层还可以细分以包月制购买的是否到期,总之被拦截的可能性很多,但启动路由的一端却无从知晓。
设计上,最简单可以是一个code,也可以封装为一个error对象,我相信你们设计经验更丰富会找到合适的办法
from drouter.
是个好提议,现在的拦截和result是没有建立任何联系的,你应该是通过在request中增加了参数,这样确实不优雅,应该从result去拿比较合理。
是不是可以这样,在返回的result里增加一个statusCode属性,预定义几个,业务方也可以定义自己的。
在拦截的时候可以传递一个statusCode过来,这样在result中就可以获取到了
// status code example // Users can customize their own status code public static final int SUCCESS = 200; public static final int NOT_FOUND = 404; public static final int INTERCEPT = 500;
from drouter.
// 拦截,附带错误码
request.getInterceptor().onInterrupt(500);// 通过result中获取错误码
DRouter.build("/activity/interceptor")
.start(this) { result ->
Toast.makeText(this@MainActivity, "状态码: ${result.statusCode}", Toast.LENGTH_LONG).show()
}
这样是否符合你的诉求?如果有更好的建议欢迎交流。
from drouter.
// 拦截,附带错误码
request.getInterceptor().onInterrupt(500);
// 通过result中获取错误码
DRouter.build("/activity/interceptor")
.start(this) { result ->
Toast.makeText(this@MainActivity, "状态码: ${result.statusCode}", Toast.LENGTH_LONG).show()
}这样是否符合你的诉求?如果有更好的建议欢迎交流。
是的,这样设计好很多
from drouter.
OK,代码已提交,感谢反馈
api 'io.github.didi:drouter-api:2.4.6'
from drouter.
Related Issues (20)
- 如何获取路由中携带的参数 HOT 1
- Support Gradle's configuration cache HOT 1
- io.github.didi:drouter-plugin-proxy id plugin HOT 1
- 能否将Request中的ActivityResultLauncher设置为public? HOT 1
- SHA-256 digest error for org/bouncycastle/asn1/cmc/BodyPartReference.class HOT 5
- Upgrade to gradle 8.0+ HOT 3
- 当使用activityResultLauncher的时候没有看见unregister的调用地方,是否需要手动取消
- 动态模块可以用吗? HOT 1
- javassist 引发的内测泄漏,导致transform临时文件无法被删除 HOT 3
- [Compose] 引入 DRouter 后 Compose 真机预览无法使用 HOT 2
- 页面路由动画 HOT 4
- 偶现编译报错, Output mapping should be non-incremental. HOT 3
- RouterPageStack类,手机物理返回键退栈问题
- 希望能添加自定义的 excludePackage
- dynamic feature模块如何使用?
- 新版依赖插件方式无效,找不到 drouter plugin HOT 1
- XXXDRouterTask产物导致编译时间增加5min+ HOT 1
- 插件扫描遍历时缓存为何不支持windows系统的
- README中图片加载不出来了
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from drouter.