我有一个用于处理多部分/混合请求的小型 Spring Boot 应用程序。
multipart/mixed 请求可以包含我的服务处理的请求列表。那么如何从多部分/混合端点中调用我的端点?另外,我需要在调用端点时保留上下文,因为我不想重做某些事情?
这可能吗 ?
另外,我该如何处理这种多部分/混合请求类型?
自己阅读和解析请求绝对容易出错且不整洁。
这是一个示例代码-=
@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;
}