Giter VIP home page Giter VIP logo

Comments (3)

getActivity avatar getActivity commented on June 9, 2024

小伙子,首先纠正你一点,这个问题属于你的 Bug,不是框架的 Bug,框架提供全局请求头或者全局参数设置,一旦设置了就是全局生效,你说的那种场景根本不能那样写,在多并发的情况下 100% 会有 Bug。

from easyhttp.

getActivity avatar getActivity commented on June 9, 2024

如果要针对你说的这种场景做适配,可以先给 Api 类实现某个接口,然后再给 EasyHttp 设置全局的拦截器,在拦截器中做判断 Api 类是否实现某个接口了,再去添加不同的请求头或者请求参数。

EasyConfig.getInstance().setInterceptor(new IRequestInterceptor() {
    @Override
    public void interceptArguments(@NonNull HttpRequest<?> httpRequest, @NonNull HttpParams params, @NonNull HttpHeaders headers) {
        if (httpRequest.getRequestApi() instanceof Xxx) {
            headers.put("X-Auth-Token", "xxxx");
        } else {
            headers.put("X-Auth-Token", "xxxx");
        }
    }
});

from easyhttp.

1415605750 avatar 1415605750 commented on June 9, 2024

好的,感谢大佬,明白了

from easyhttp.

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.