You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@servicecomb.apache.org by GitBox <gi...@apache.org> on 2021/05/24 13:38:46 UTC

[GitHub] [servicecomb-java-chassis] yfliuas opened a new issue #2393: 添加AOP拦截controller,切面始终无法生效

yfliuas opened a new issue #2393:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2393


   【说明】
   我们的业务场景是希望在请求之后获取responseBody,然后根据响应体写操作日志。
   问题转化----->请求做个切面,拦截resposeBody
   【尝试方案一】
   使用HttpServerFilter,在使用@RestSchema的接口下可以正常工作,但是环境中存在大量的@RPCSchema注册的接口,此类接口使用HttpServerFilter拦截不到
   【尝试方案二】
   使用Handler,在原始的Handler可以获取requestBody,但是拿不到responseBody
   【尝试方案三】
   使用AOP,由于我们的场景是做一个SDK类似的东西,尽可能不想让用户感知到细节,所以使用注解定义切面,这种场景下用户在接口前新增一个@AutoOperationLog,当有改注解时,记录操作日志,如果没有则do nothing。
   
   第三种方案在controller前面拦截,直接报失败返回:
   400 17ms 
   content-length : 70
   Content-Type : text/plain; charset=utf-8
   
   CommonExceptionData [message=Parameters not valid or types not match.]
   
   @liubao68 求教一下,就我的这个使用场景,目前java-chassis是否有更合适的机制解决?使用AOP拦截的第三种方案如何解决?


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] wujimin commented on issue #2393: Parameters not valid or types not match

Posted by GitBox <gi...@apache.org>.
wujimin commented on issue #2393:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2393#issuecomment-847211428


   `根据响应体写操作日志`,应该不是个好主意  
   原因:  
   * 这意味着,拿着序列化好的应答串,重新反序列为map,再决策的意思  
   * 写日志的序列化,与应答的序列化需求,应该是有差异的  
     比如,敏感信息不可以写到日志中去 
   
   一个可能的方案:
   * 建立公共脱敏机制,比如在敏感字段上打上annotation,声明需要如何脱敏  
     脱敏逻辑只在写日志序列化时生效  
   *  使用aop,或在ProducerOperationHandler 之前加一个handler,均可拿到Response对象,里面就有controller return的数据模型
   


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org



[GitHub] [servicecomb-java-chassis] liubao68 commented on issue #2393: Parameters not valid or types not match

Posted by GitBox <gi...@apache.org>.
liubao68 commented on issue #2393:
URL: https://github.com/apache/servicecomb-java-chassis/issues/2393#issuecomment-847071745


   1. 尝试方案一: 不管是RestSchema还是RpcSchema, 应该都会在HttpServerFilter, 流程是一致的
   2. 尝试方案三:不是很清楚是怎么做的。 建议提供一个DEMO例子,便于分析。 也可以尝试调试下:ProducerOperationHandler ,看看是什么导致的错误。 


-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

For queries about this service, please contact Infrastructure at:
users@infra.apache.org