I am trying to create a response inside a handler with actix-web v4.
The header
method has changed to append_header
which now instead of a key value pair takes a header object.
The original documentation here gives the following example:
use actix_web::HttpResponse;
async fn index() -> HttpResponse {
HttpResponse::Ok()
.content_type("plain/text")
.header("X-Hdr", "sample")
.body("data")
}
I can create a header with append_header(ContentType::plaintext())
with a predefined mime name, but I haven't found any way to create a custom type.
I would have expected something like Header::from("'X-Hdr': 'sample'")
to work but haven't found any way to create this header.
What would be the right way to create the 'X-Hdr':'sample'
header in actix-web v4?