~repos /rust-embed
git clone https://pyrossh.dev/repos/rust-embed.git
rust macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.
07c59d08
—
Mark Drobnak 5 years ago
Merge pull request #112 from paolobarbolini/actix-example
- examples/actix.rs +4 -5
examples/actix.rs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
use actix_web::body::Body;
|
|
2
|
-
use actix_web::{web, App,
|
|
2
|
+
use actix_web::{web, App, HttpResponse, HttpServer};
|
|
3
3
|
use mime_guess::from_path;
|
|
4
4
|
use rust_embed::RustEmbed;
|
|
5
5
|
|
|
@@ -22,13 +22,12 @@ fn handle_embedded_file(path: &str) -> HttpResponse {
|
|
|
22
22
|
}
|
|
23
23
|
}
|
|
24
24
|
|
|
25
|
-
fn index(
|
|
25
|
+
fn index() -> HttpResponse {
|
|
26
26
|
handle_embedded_file("index.html")
|
|
27
27
|
}
|
|
28
28
|
|
|
29
|
-
fn dist(
|
|
29
|
+
fn dist(path: web::Path<(String,)>) -> HttpResponse {
|
|
30
|
-
let path = &req.path()["/dist/".len()..]; // trim the preceding `/dist/` in path
|
|
31
|
-
handle_embedded_file(path)
|
|
30
|
+
handle_embedded_file(&path.0)
|
|
32
31
|
}
|
|
33
32
|
|
|
34
33
|
#[actix_rt::main]
|