chore: update actix-* deps

This commit is contained in:
realaravinth
2022-05-07 16:10:14 +05:30
parent 6d6b494c6f
commit 91c6f77cab
16 changed files with 1101 additions and 1006 deletions

View File

@@ -16,7 +16,7 @@
*/
use std::borrow::Cow;
use actix_web::body::AnyBody;
use actix_web::body::BoxBody;
use actix_web::{http::header, web, HttpResponse, Responder};
use mime_guess::from_path;
use rust_embed::RustEmbed;
@@ -54,12 +54,15 @@ struct Asset;
pub fn handle_embedded_file(path: &str) -> HttpResponse {
match Asset::get(path) {
Some(content) => {
let body: AnyBody = match content.data {
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()
.insert_header(header::CacheControl(vec![
header::CacheDirective::Public,
header::CacheDirective::Extension("immutable".into(), None),
header::CacheDirective::MaxAge(CACHE_AGE),
]))
.content_type(from_path(path).first_or_octet_stream().as_ref())
@@ -69,6 +72,7 @@ pub fn handle_embedded_file(path: &str) -> HttpResponse {
}
}
#[my_codegen::get(path = "DOCS.assets")]
async fn dist(path: web::Path<String>) -> impl Responder {
handle_embedded_file(&path)