public interface GlobalHttpHandler
GlobalConfigModule.Builder#globalHttpHandler(GlobalHttpHandler) 方法配置| Modifier and Type | Field and Description |
|---|---|
static GlobalHttpHandler |
EMPTY
空实现
|
| Modifier and Type | Method and Description |
|---|---|
Request |
onHttpRequestBefore(Interceptor.Chain chain,
Request request)
这里可以在请求服务器之前拿到
Request, 做一些操作比如给 Request 统一添加 token 或者 header 以及参数加密等操作 |
Response |
onHttpResultResponse(java.lang.String httpResult,
Interceptor.Chain chain,
Response response)
这里可以先客户端一步拿到每一次 Http 请求的结果, 可以先解析成 Json, 再做一些操作, 如检测到 token 过期后
重新请求 token, 并重新执行请求
|
static final GlobalHttpHandler EMPTY
Response onHttpResultResponse(java.lang.String httpResult,
Interceptor.Chain chain,
Response response)
httpResult - 服务器返回的结果 (已被框架自动转换为字符串)chain - okhttp3.Interceptor.Chainresponse - ResponseResponseRequest onHttpRequestBefore(Interceptor.Chain chain,
Request request)
Request, 做一些操作比如给 Request 统一添加 token 或者 header 以及参数加密等操作chain - okhttp3.Interceptor.Chainrequest - RequestRequest