Añade librería para gestionar recursos estáticos (#1)

Reviewed-on: #1
Co-authored-by: Manuel Cillero <manuel@cillero.es>
Co-committed-by: Manuel Cillero <manuel@cillero.es>
This commit is contained in:
Manuel Cillero 2025-08-08 23:58:07 +02:00 committed by Manuel Cillero
parent 8ed0e6621a
commit 47ea9d9f7d
20 changed files with 1371 additions and 41 deletions

View file

@ -98,21 +98,23 @@ use std::ops::Deref;
pub use pagetop_macros::{builder_fn, html, main, test, AutoDefault};
pub use pagetop_statics::{resource, StaticResource};
/// Conjunto de recursos asociados a `$STATIC` en [`include_files!`](crate::include_files).
pub struct StaticResources {
bundle: HashMap<&'static str, static_files::Resource>,
bundle: HashMap<&'static str, StaticResource>,
}
impl StaticResources {
/// Crea un contenedor para un conjunto de recursos generado por `build.rs` (consultar
/// [`pagetop_build`](https://docs.rs/pagetop-build)).
pub fn new(bundle: HashMap<&'static str, static_files::Resource>) -> Self {
pub fn new(bundle: HashMap<&'static str, StaticResource>) -> Self {
Self { bundle }
}
}
impl Deref for StaticResources {
type Target = HashMap<&'static str, static_files::Resource>;
type Target = HashMap<&'static str, StaticResource>;
fn deref(&self) -> &Self::Target {
&self.bundle

View file

@ -8,9 +8,9 @@ pub use actix_web::dev::ServiceRequest as Request;
pub use actix_web::dev::ServiceResponse as Response;
pub use actix_web::{cookie, http, rt, web};
pub use actix_web::{App, Error, HttpMessage, HttpRequest, HttpResponse, HttpServer};
pub use actix_web_files::Files as ActixFiles;
pub use actix_web_static_files::ResourceFiles;
pub use pagetop_statics::ResourceFiles;
#[doc(hidden)]
pub use actix_web::test;