Popeye
Popeye

Reputation: 1558

Override REST POST method based on type of request

I am using resteasy and I want to have two post methods like this -

@POST    
@Consumes("multipart/form-data")
public void post(   @PathParam("p1") String p1, 
                        @PathParam("p2") String p2,
                        @PathParam("p3") String p3,
                        @Suspended AsyncResponse asyncResponse, 
                        @Context HttpServletRequest httpServletRequest,
                        MultipartFormDataInput input)
@POST    
public void post(   @PathParam("p1") String p1, 
                            @PathParam("p2") String p2,
                            @PathParam("p3") String p3,
                            @Suspended AsyncResponse asyncResponse, 
                            @Context HttpServletRequest httpServletRequest)

First post method to handle file uploads and other post method to handle all requests except file uploads. But when I test these methods, file upload works fine but requests other than file upload do not reach any of these methods. How can I achieve this? Also, I am fine if I can somehow receive both types of requests in a single method and then handle the requests conditionally based on whether file was uploaded or not...

Upvotes: 0

Views: 519

Answers (1)

Popeye
Popeye

Reputation: 1558

Oh..Sorry guys.. Must be a build issue because the above method signatures are working fine.. :)

Upvotes: 1

Related Questions