Package com.unfbx.chatgpt.interceptor
Class DynamicKeyOpenAiAuthInterceptor
- java.lang.Object
-
- com.unfbx.chatgpt.interceptor.OpenAiAuthInterceptor
-
- com.unfbx.chatgpt.interceptor.DynamicKeyOpenAiAuthInterceptor
-
- All Implemented Interfaces:
okhttp3.Interceptor
public class DynamicKeyOpenAiAuthInterceptor extends OpenAiAuthInterceptor
描述:动态处理key的鉴权拦截器- Since:
- 2023-04-25
- Author:
- https:www.unfbx.com
-
-
Constructor Summary
Constructors Constructor Description DynamicKeyOpenAiAuthInterceptor()请求头处理DynamicKeyOpenAiAuthInterceptor(Map warringConfig)构造方法
-
Method Summary
All Methods Instance Methods Concrete Methods Modifier and Type Method Description okhttp3.Requestauth(String key, okhttp3.Request original)默认的鉴权处理方法okhttp3.Responseintercept(okhttp3.Interceptor.Chain chain)protected voidnoHaveActiveKeyWarring()所有的key都失效后,自定义预警配置 不配置直接returnprotected List<String>onErrorDealApiKeys(String errorKey)自定义apiKeys的处理逻辑-
Methods inherited from class com.unfbx.chatgpt.interceptor.OpenAiAuthInterceptor
getKey
-
-
-
-
Constructor Detail
-
DynamicKeyOpenAiAuthInterceptor
public DynamicKeyOpenAiAuthInterceptor()
请求头处理
-
DynamicKeyOpenAiAuthInterceptor
public DynamicKeyOpenAiAuthInterceptor(Map warringConfig)
构造方法- Parameters:
warringConfig- 所有的key都失效后的告警参数配置
-
-
Method Detail
-
intercept
public okhttp3.Response intercept(okhttp3.Interceptor.Chain chain) throws IOException- Throws:
IOException
-
onErrorDealApiKeys
protected List<String> onErrorDealApiKeys(String errorKey)
Description copied from class:OpenAiAuthInterceptor自定义apiKeys的处理逻辑- Specified by:
onErrorDealApiKeysin classOpenAiAuthInterceptor- Parameters:
errorKey- 错误的key- Returns:
- 返回值是新的apiKeys
-
noHaveActiveKeyWarring
protected void noHaveActiveKeyWarring()
所有的key都失效后,自定义预警配置 不配置直接return- Specified by:
noHaveActiveKeyWarringin classOpenAiAuthInterceptor
-
auth
public okhttp3.Request auth(String key, okhttp3.Request original)
Description copied from class:OpenAiAuthInterceptor默认的鉴权处理方法- Overrides:
authin classOpenAiAuthInterceptor- Parameters:
key- api keyoriginal- 源请求体- Returns:
- 请求体
-
-