alibabacloud-go / tea

Apache License 2.0
36 stars 21 forks source link

能否支持暴露拦截器,给外部使用时传入 #69

Open honwhy opened 2 years ago

honwhy commented 2 years ago

拦截器实现参考:https://dev.to/clavinjune/golang-http-client-interceptors-2ebe

image 不修改response_, _err := tea.DoRequest(request_, _runtime)调用方式, 设置全局拦截器。 类似Java的做法(Darabonba codegen的java项目有拦截器机制)

public class Client {

    private final static InterceptorChain interceptorChain = InterceptorChain.create();
    public Client(Config config) throws Exception {
        ...
           interceptorChain.addRequestInterceptor(new RequestInterceptor() {
            @Override
            public TeaRequest modifyRequest(InterceptorContext context, AttributeMap attributes) {
                return null;
            }
        });
    }
yndu13 commented 1 year ago

好的,感谢建议,我们评估下