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 2019/06/28 01:01:27 UTC

[GitHub] [servicecomb-java-chassis] guanhaobi opened a new issue #1249: 参数校验GET方式请求不生效,POST方式请求正常

guanhaobi opened a new issue #1249: 参数校验GET方式请求不生效,POST方式请求正常
URL: https://github.com/apache/servicecomb-java-chassis/issues/1249
 
 
   按照文档,配置了ExceptionToProducerResponseConverter,发现下POST请求下可以正常处理自定义的参数校逻辑,GET方式请求下,无法进入自定义参数校验逻辑,debug调试发现这两种请求方式下,框架的方法调用栈不一样:
   public class ConstraintViolationExceptionToProducerResponseConverter
       implements ExceptionToProducerResponseConverter<ConstraintViolationException> {
     @Override
     public Class<ConstraintViolationException> getExceptionClass() {
         return ConstraintViolationException.class;
     }
   
     @Override
     public Response convert(SwaggerInvocation swaggerInvocation, ConstraintViolationException e) {
         Map<String,Object> errorInfo = new HashMap<>(2);
         errorInfo.put("rtnCode",1);
         errorInfo.put("rtnDesc":"Parameter valid faild.")
        return Response.createFail(new InvocationException(Status.BAD_REQUEST, errorInfo ));
     }
   
     @Override
     public int getOrder() {
         return -200;
     }
   }

----------------------------------------------------------------
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


With regards,
Apache Git Services