chunk qui marche
This commit is contained in:
parent
81c9669e17
commit
02245bf01c
|
@ -11,8 +11,10 @@ actix-web = "3.3.2"
|
||||||
actix-session = "0.4.1"
|
actix-session = "0.4.1"
|
||||||
actix-web-httpauth = "0.5.1"
|
actix-web-httpauth = "0.5.1"
|
||||||
actix-files = "0.5.0"
|
actix-files = "0.5.0"
|
||||||
|
actix-utils = "2.0.0"
|
||||||
askama = "0.10.5"
|
askama = "0.10.5"
|
||||||
askama_actix = "0.11.1"
|
askama_actix = "0.11.1"
|
||||||
env_logger = "0.8.4"
|
env_logger = "0.8.4"
|
||||||
serde = "1.0.126"
|
serde = "1.0.126"
|
||||||
futures = "0.3.15"
|
futures = "0.3.15"
|
||||||
|
tokio = {version = "0.2.25", features = ["time"]}
|
||||||
|
|
19
src/main.rs
19
src/main.rs
|
@ -100,6 +100,24 @@ struct GitWebQ {
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
#[get("/chunk")]
|
||||||
|
async fn chunk() -> HttpResponse {
|
||||||
|
let (tx, rx) = actix_utils::mpsc::channel::<Result<Bytes, Error>>();
|
||||||
|
actix_web::rt::spawn(async move {
|
||||||
|
if tx.send(Ok(Bytes::from_static(b"trying to echo"))).is_err() {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
|
||||||
|
while true {
|
||||||
|
tokio::time::delay_for(std::time::Duration::from_secs(1)).await;
|
||||||
|
println!("send message");
|
||||||
|
tx.send(Ok(Bytes::from_static(b"coucou")));
|
||||||
|
}
|
||||||
|
});
|
||||||
|
|
||||||
|
HttpResponse::Ok().streaming(rx)
|
||||||
|
}
|
||||||
|
|
||||||
#[get("/git/{owner}/{repo}.git")]
|
#[get("/git/{owner}/{repo}.git")]
|
||||||
async fn git_main(web::Path((owner, reponame)): web::Path<(String, String)>, web::Query(GitWebQ{commit : commitnameopt, path : pathopt}) : web::Query<GitWebQ>) -> impl Responder {
|
async fn git_main(web::Path((owner, reponame)): web::Path<(String, String)>, web::Query(GitWebQ{commit : commitnameopt, path : pathopt}) : web::Query<GitWebQ>) -> impl Responder {
|
||||||
let commitname = match commitnameopt {
|
let commitname = match commitnameopt {
|
||||||
|
@ -292,6 +310,7 @@ async fn main() -> std::io::Result<()> {
|
||||||
.service(askama)
|
.service(askama)
|
||||||
.service(git_main)
|
.service(git_main)
|
||||||
.service(hello_session)
|
.service(hello_session)
|
||||||
|
.service(chunk)
|
||||||
//.service(git_proto)
|
//.service(git_proto)
|
||||||
// .service(
|
// .service(
|
||||||
// web::scope("/auth")
|
// web::scope("/auth")
|
||||||
|
|
Loading…
Reference in New Issue