mirror of
https://github.com/actix/examples
synced 2024-11-23 22:41:07 +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 {
|
||||
let name = path.into_inner();
|
||||
|
||||
HttpResponse::Ok().streaming(stream! {
|
||||
yield Ok::<_, Infallible>(web::Bytes::from("Hello "));
|
||||
yield Ok::<_, Infallible>(web::Bytes::from(name));
|
||||
yield Ok::<_, Infallible>(web::Bytes::from("!"));
|
||||
})
|
||||
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("!"));
|
||||
})
|
||||
}
|
||||
|
||||
/// handler with path parameters like `/user/{name}/`
|
||||
|
Loading…
Reference in New Issue
Block a user