kazetyan commented on issue #13287:
URL: https://github.com/apache/dubbo/issues/13287#issuecomment-1867454337
看了下这块的代码,`javax.ws.rs.core.Response`
类型的返回值只对body做了codec,没有对status做处理,你可以自定义一个`RestResponseInterceptor` 来处理
```java
@Activate(value = "rsResp", onClass = {"javax.ws.rs.core.Response"})
public class RsResponseInterceptor implements RestResponseInterceptor {
@Override
public void intercept(RestInterceptContext restResponseInterceptor)
throws Exception {
if (restResponseInterceptor.getResult() instanceof Response) {
Response result = (Response) restResponseInterceptor.getResult();
restResponseInterceptor.getResponse().setStatus(result.getStatus());
}
}
}
```
添加spi文件

```plain
rsResp=org.apache.dubbo.demo.rest.api.extension.RsResponseInterceptor
```
### 测试
```java
@DELETE
@Path("{uid}")
public Response deleteUserById(@PathParam("uid") String uid) {
return Response.status(300).entity("deleted").build();
}
```

<br/>
不确定dubbo是否应该内置这个`RestResponseInterceptor` ,或者其他更好的方式来处理
--
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.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]