mirror of
https://github.com/actix/examples
synced 2025-03-20 18:45:17 +01:00
add content_type for basic example response body to decode utf-8 correctly (#586)
This commit is contained in:
parent
6fe45afe69
commit
32022a5ec1
@ -58,11 +58,13 @@ async fn default_handler(req_method: Method) -> Result<impl Responder> {
|
|||||||
async fn response_body(path: web::Path<String>) -> HttpResponse {
|
async fn response_body(path: web::Path<String>) -> HttpResponse {
|
||||||
let name = path.into_inner();
|
let name = path.into_inner();
|
||||||
|
|
||||||
HttpResponse::Ok().streaming(stream! {
|
HttpResponse::Ok()
|
||||||
yield Ok::<_, Infallible>(web::Bytes::from("Hello "));
|
.content_type(ContentType::plaintext())
|
||||||
yield Ok::<_, Infallible>(web::Bytes::from(name));
|
.streaming(stream! {
|
||||||
yield Ok::<_, Infallible>(web::Bytes::from("!"));
|
yield Ok::<_, Infallible>(web::Bytes::from("Hello "));
|
||||||
})
|
yield Ok::<_, Infallible>(web::Bytes::from(name));
|
||||||
|
yield Ok::<_, Infallible>(web::Bytes::from("!"));
|
||||||
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
/// handler with path parameters like `/user/{name}/`
|
/// handler with path parameters like `/user/{name}/`
|
||||||
|
Loading…
x
Reference in New Issue
Block a user