MCPcopy Create free account
hub / github.com/actix/examples / streaming_response

Function streaming_response

basics/basics/src/main.rs:58–68  ·  view source on GitHub ↗
(path: web::Path<String>)

Source from the content-addressed store, hash-verified

56}
57
58async fn streaming_response(path: web::Path<String>) -> HttpResponse {
59 let name = path.into_inner();
60
61 HttpResponse::Ok()
62 .content_type(ContentType::plaintext())
63 .streaming(stream! {
64 yield Ok::<_, Infallible>(web::Bytes::from("Hello "));
65 yield Ok::<_, Infallible>(web::Bytes::from(name));
66 yield Ok::<_, Infallible>(web::Bytes::from("!"));
67 })
68}
69
70/// handler with path parameters like `/user/{name}`
71async fn with_param(req: HttpRequest, Path((name,)): Path<(String,)>) -> HttpResponse {

Callers

nothing calls this directly

Calls

no outgoing calls

Tested by

no test coverage detected