actix-plus-static-files 0.1.0

A library that integrates with actix-web and include_dir to cleanly package, via a macro, static resources (e.g. a frontend) with an actix-web binary, thus serving these resources from RAM at runtime and simplifying deployment by containing the entire web application in a single executable binary; Fork of actix-web-static-files by Alexander Korolev
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use actix_plus_static_files::{build_hashmap_from_included_dir, include_dir, Dir, ResourceFiles};
use actix_web::{App, HttpServer};

const DIR: Dir = include_dir!("./examples/static");

#[actix_web::main]
async fn main() {
    HttpServer::new(|| {
        let hash_map = build_hashmap_from_included_dir(&DIR);
        App::new().service(ResourceFiles::new("/", hash_map))
    })
    .bind("127.0.0.1:8192")
    .expect("Failed to bind to port")
    .run()
    .await
    .expect("Failed to run server");
}