diff --git a/Cargo.lock b/Cargo.lock index 9324936..d649b9b 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -270,6 +270,15 @@ dependencies = [ "generic-array", ] +[[package]] +name = "block-buffer" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1d36a02058e76b040de25a4464ba1c80935655595b661505c8b39b664828b95" +dependencies = [ + "generic-array", +] + [[package]] name = "brotli-sys" version = "0.3.2" @@ -321,7 +330,7 @@ dependencies = [ "mime_guess", "serde", "serde_json", - "sha2", + "sha2 0.10.0", "walkdir", ] @@ -381,6 +390,15 @@ dependencies = [ "cfg-if", ] +[[package]] +name = "crypto-common" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "683d6b536309245c849479fba3da410962a43ed8e51c26b729208ec0ac2798d0" +dependencies = [ + "generic-array", +] + [[package]] name = "darling" version = "0.12.4" @@ -475,6 +493,17 @@ dependencies = [ "generic-array", ] +[[package]] +name = "digest" +version = "0.10.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b697d66081d42af4fba142d56918a3cb21dc8eb63372c6b85d14f44fb9c5979b" +dependencies = [ + "block-buffer 0.10.0", + "crypto-common", + "generic-array", +] + [[package]] name = "discard" version = "1.0.4" @@ -1088,7 +1117,7 @@ version = "7.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "ad22c7226e4829104deab21df575e995bfbc4adfad13a595e387477f238c1aec" dependencies = [ - "sha2", + "sha2 0.9.8", "walkdir", ] @@ -1201,10 +1230,10 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "99cd6713db3cf16b6c84e06321e049a9b9f699826e16096d23bbcc44d15d51a6" dependencies = [ - "block-buffer", + "block-buffer 0.9.0", "cfg-if", "cpufeatures", - "digest", + "digest 0.9.0", "opaque-debug", ] @@ -1220,13 +1249,24 @@ version = "0.9.8" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "b69f9a4c9740d74c5baa3fd2e547f9525fa8088a8a958e0ca2409a514e33f5fa" dependencies = [ - "block-buffer", + "block-buffer 0.9.0", "cfg-if", "cpufeatures", - "digest", + "digest 0.9.0", "opaque-debug", ] +[[package]] +name = "sha2" +version = "0.10.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "900d964dd36bb15bcf2f2b35694c072feab74969a54f2bbeec7a2d725d2bdcb6" +dependencies = [ + "cfg-if", + "cpufeatures", + "digest 0.10.1", +] + [[package]] name = "signal-hook-registry" version = "1.4.0" diff --git a/examples/actix-web/src/main.rs b/examples/actix-web/src/main.rs index d8f08f2..17fd3db 100644 --- a/examples/actix-web/src/main.rs +++ b/examples/actix-web/src/main.rs @@ -1,6 +1,6 @@ use std::borrow::Cow; -use actix_web::body::Body; +use actix_web::body::BoxBody; use actix_web::{get, http::header, web, HttpResponse, Responder}; use actix_web::{App, HttpServer}; use lazy_static::lazy_static; @@ -19,7 +19,7 @@ lazy_static! { /// 2. create filemap pub static ref FILES: Files = { let map = include_str!("./cache_buster_data.json"); - Files::new(&map) + Files::new(map) }; pub static ref INDEX: String = index::get_index(); } @@ -53,9 +53,9 @@ struct Asset; fn handle_assets(path: &str) -> HttpResponse { match Asset::get(path) { Some(content) => { - let body: Body = match content { - Cow::Borrowed(bytes) => bytes.into(), - Cow::Owned(bytes) => bytes.into(), + let body: BoxBody = match content.data { + Cow::Borrowed(bytes) => BoxBody::new(bytes), + Cow::Owned(bytes) => BoxBody::new(bytes), }; HttpResponse::Ok() @@ -80,9 +80,10 @@ pub async fn static_files(path: web::Path) -> impl Responder { #[get("/")] pub async fn serve_index() -> impl Responder { + let index: &str = &*INDEX; HttpResponse::Ok() .content_type("text/html; charset=utf-8") - .body(&*INDEX) + .body(index) } #[derive(RustEmbed)] @@ -92,9 +93,9 @@ struct Favicons; fn handle_favicons(path: &str) -> HttpResponse { match Favicons::get(path) { Some(content) => { - let body: Body = match content { - Cow::Borrowed(bytes) => bytes.into(), - Cow::Owned(bytes) => bytes.into(), + let body: BoxBody = match content.data { + Cow::Borrowed(bytes) => BoxBody::new(bytes), + Cow::Owned(bytes) => BoxBody::new(bytes), }; HttpResponse::Ok()