Info
This post is auto-generated from RSS feed The Rust Programming Language Forum - Latest topics. Source: Answer HttpResponse with JSON+ PDF?
Hi,
I am working on document generation.
I need to add a service in API to answer the PDF generated + Json (with a lot of comment about the generation : what cannot be included, what not available, etc...).
For now, I only use a way to answer the PDF document like this :
Ok(pdf: Vec<u8>) => Ok(HttpResponse::Ok().content_type("application/pdf").body(pdf)),
I use header for my answer that is a application/pdf.
After reading documentation, I discover we can use "multipart" header for request. But not seems to be available for answer ?
I was thinking to add my Vec<u8>
data for the pdf in some field of json but I think I will have maybe problem with character to escape like ".
So I am searching a way and I wonder if there is already a way for this kind of feature ? Because I think is really usefull to answer many type of data.
Have you already use multipart for an answer to a request ?
I discover this crate, trying to understand it, if for the answer it can be used... https://docs.rs/multipart/latest/multipart/server/index.html
7 posts - 4 participants
🏷️ Rust_feed