Closed goodclouddata closed 5 years ago
fn foo(&self) -> Result<http::Response<bytes::Bytes>, Error> {
let png_bytes: Vec<u8> = /* ... */;
Ok(http::Response::builder()
.status(200)
.header(http::header::CONTENT_TYPE, "image/png")
.body(png_bytes.into())?
)
}
@kornholl ,Thanks a lot!
I wonder if there should be some built in types for this kind of stuff...
#[derive(Response)]
#[web(header(name = "content-type", value = "image/png"))]
pub struct Png {
body: Bytes,
}
I want to output the png format to web,How to do this now? set content_type:image/png. if use Result<http::Response<Vec> ,Error> type, tower-web-0.3.3/src/response/context.rs line : 107 WARN: no default serialization format associated with action