Skip to content

Commit

Permalink
fix: set default value for accept (#13199)
Browse files Browse the repository at this point in the history
Co-authored-by: 贾彦昭 <[email protected]>
  • Loading branch information
imJYZ and 贾彦昭 authored Oct 14, 2023
1 parent 4782142 commit a4a3fd7
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,7 @@
import org.apache.dubbo.rpc.protocol.rest.util.MediaTypeUtil;

import java.util.List;
import java.util.Objects;

@Activate(value = "invoke", order = Integer.MAX_VALUE)
public class ServiceInvokeRestFilter implements RestRequestFilter {
Expand Down Expand Up @@ -179,6 +180,7 @@ public static void writeResult(NettyHttpResponse nettyHttpResponse, URL url, Obj
*/
public static MediaType getAcceptMediaType(RequestFacade request, Class<?> returnType) {
String accept = request.getHeader(RestHeaderEnum.ACCEPT.getHeader());
accept = Objects.isNull(accept) ? MediaType.ALL_VALUE.value : accept;
MediaType mediaType = MediaTypeUtil.convertMediaType(returnType, accept);
return mediaType;
}
Expand Down

0 comments on commit a4a3fd7

Please sign in to comment.