~repos /rust-embed

#rust#proc-macro#http

git clone https://pyrossh.dev/repos/rust-embed.git
Discussions: https://groups.google.com/g/rust-embed-devs

rust macro which loads files into the rust binary at compile time during release and loads the file from the fs during dev.


Files changed (3) hide show
  1. Cargo.toml +1 -2
  2. examples/actix.rs +13 -0
  3. examples/rouille.rs +0 -20
Cargo.toml CHANGED
@@ -23,8 +23,7 @@ rocket_codegen = { version = "0.3.6", optional = true }
23
23
  rocket_contrib = { version = "0.3.6", optional = true }
24
24
 
25
25
  [dev-dependencies]
26
- rouille = "2.1.0"
26
+ actix-web = "0.6"
27
- fern = "0.5"
28
27
 
29
28
  [features]
30
29
  nightly = ["rocket", "rocket_codegen", "rocket_contrib"]
examples/actix.rs ADDED
@@ -0,0 +1,13 @@
1
+ extern crate actix_web;
2
+ use actix_web::{server, App, HttpRequest};
3
+
4
+ fn index(_req: HttpRequest) -> &'static str {
5
+ "Hello world!"
6
+ }
7
+
8
+ fn main() {
9
+ server::new(|| App::new().resource("/", |r| r.f(index)))
10
+ .bind("127.0.0.1:8000")
11
+ .unwrap()
12
+ .run();
13
+ }
examples/rouille.rs DELETED
@@ -1,20 +0,0 @@
1
- extern crate rouille;
2
-
3
- use rouille::Response;
4
-
5
- // TBD
6
- fn main() {
7
- println!("Now listening on localhost:8000");
8
- rouille::start_server("localhost:8000", move |request| {
9
- {
10
- let response = rouille::match_assets(&request, ".");
11
- if response.is_success() {
12
- return response;
13
- }
14
- }
15
- Response::html(
16
- "404 error. Try <a href=\"/README.md\"`>README.md</a> or \
17
- <a href=\"/src/lib.rs\">src/lib.rs</a> for example.",
18
- ).with_status_code(404)
19
- });
20
- }