0

I have a small spring boot application for handling multipart/mixed requests.

The multipart/mixed request can contain a list of requests my service handles. So how do I call my endpoints from within the multipart/mixed endpoint ? Also, I need to preserve the context while calling the endpoints as I dont want to redo certain things ?

Is this possible ?

Also, how do I handle such multipart/mixed request types ?

Reading and parsing requests myself is definitely error-prone and not neat.

Here is a sample code -=

@Path("/api")
public class Demo {

    @GET
    public String test() {
        return "hello";
    }

    // Echo back the multipart that was sent
    @Path("twelve")
    @PUT
    @Consumes("multipart/mixed")
    @Produces("multipart/mixed")
    public MultiPart twelve( MultiPart multiPart) throws IOException {

    List<BodyPart> bodyParts = multiPart.getBodyParts();

    // The list of bodyParts will contain list of requests which my service is handling like
    // GET on /api in this case. I want to invoke test() from here within the same context.

    return multiPart;
    }
  • sure, you can do it, just call client by passing applicationContext, request, response, url, method type, what is the issue?, do you need response of all requests as part of final response?, that too you can do, but it may increase response time. – dkb Nov 25 '19 at 08:03
  • How ? Can you give an example how can II call the test() method by using resttemplate client ? – lostintranslation Nov 25 '19 at 12:00

0 Answers0