1
0
mirror of https://github.com/actix/examples synced 2024-11-27 16:02:57 +01:00

add content_type for basic example response body to decode utf-8 correctly (#586)

This commit is contained in:
Zhengliang Wu 2022-11-21 22:47:48 +08:00 committed by GitHub
parent 6fe45afe69
commit 32022a5ec1
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -58,7 +58,9 @@ async fn default_handler(req_method: Method) -> Result<impl Responder> {
async fn response_body(path: web::Path<String>) -> HttpResponse {
let name = path.into_inner();
HttpResponse::Ok().streaming(stream! {
HttpResponse::Ok()
.content_type(ContentType::plaintext())
.streaming(stream! {
yield Ok::<_, Infallible>(web::Bytes::from("Hello "));
yield Ok::<_, Infallible>(web::Bytes::from(name));
yield Ok::<_, Infallible>(web::Bytes::from("!"));