Giter Club home page Giter Club logo

Comments (6)

JessYanCoding avatar JessYanCoding commented on May 17, 2024

这个是关于retrofit及okhttp的扩展实现,百度搜索很多

from mvparms.

JessYanCoding avatar JessYanCoding commented on May 17, 2024

@WooYu 刚刚看了下,大多数做法是自定义一个 Interceptor, 你将这个 Interceptor,在WeApplication中通过GlobeConfigModule.addInterceptor(),传进来就可以了,旧版本使用 WeApplication 中的 getInterceptors() 方法,教程很多难度应该不大

from mvparms.

WooYu avatar WooYu commented on May 17, 2024

在你说的位置进行拦截,那不所有的请求都会被拦截了

from mvparms.

JessYanCoding avatar JessYanCoding commented on May 17, 2024

@WooYu Okhttp的整个实现都建立在了,Interceptor上,它内部也是使用几个Interceptor对请求进行封装,请求服务器,返回数据,所以你使用Interceptor,并不一定要将所有请求拦截,如果不符合你的条件你不拦截也不处理就可以了,这并不会对后续的请求有什么影响,Android中的事件分发机制,也是使用了责任链模式,你不处理那就不拦截就可以了,不会对后面的事件有什么影响

from mvparms.

WooYu avatar WooYu commented on May 17, 2024

from mvparms.

JessYanCoding avatar JessYanCoding commented on May 17, 2024

@WooYu 那我给你个意见,在 Interceptor 中可以拿到所有请求的header和参数,你可以在上传文件请求接口中添加一个用来区别其他请求接口的header,然后使用这个 Interceptor 判断是否含有这个 header 即可

from mvparms.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.