~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.
f207a831
—
Peter John 3 years ago
Merge pull request #199 from davidpdrsn/axum-0.6.0
- Cargo.toml +1 -1
- examples/axum.rs +3 -4
Cargo.toml
CHANGED
|
@@ -63,7 +63,7 @@ hex = { version = "0.4.3", optional = true }
|
|
|
63
63
|
tokio = { version = "1.0", optional = true, features = ["macros", "rt-multi-thread"] }
|
|
64
64
|
warp = { version = "0.3", default-features = false, optional = true }
|
|
65
65
|
rocket = { version = "0.5.0-rc.2", default-features = false, optional = true }
|
|
66
|
-
axum = { version = "0.
|
|
66
|
+
axum = { version = "0.6", default-features = false, features = ["http1", "tokio"], optional = true }
|
|
67
67
|
poem = { version = "1.3.30", default-features = false, features = ["server"], optional = true }
|
|
68
68
|
salvo = { version = "0.16", default-features = false, optional = true }
|
|
69
69
|
|
examples/axum.rs
CHANGED
|
@@ -1,11 +1,10 @@
|
|
|
1
1
|
use axum::{
|
|
2
2
|
body::{boxed, Full},
|
|
3
|
-
handler::
|
|
3
|
+
handler::HandlerWithoutStateExt,
|
|
4
4
|
http::{header, StatusCode, Uri},
|
|
5
5
|
response::{Html, IntoResponse, Response},
|
|
6
6
|
routing::{get, Router},
|
|
7
7
|
};
|
|
8
|
-
use mime_guess;
|
|
9
8
|
use rust_embed::RustEmbed;
|
|
10
9
|
use std::net::SocketAddr;
|
|
11
10
|
|
|
@@ -15,8 +14,8 @@ async fn main() {
|
|
|
15
14
|
let app = Router::new()
|
|
16
15
|
.route("/", get(index_handler))
|
|
17
16
|
.route("/index.html", get(index_handler))
|
|
18
|
-
.
|
|
17
|
+
.route_service("/dist/*file", static_handler.into_service())
|
|
19
|
-
.
|
|
18
|
+
.fallback_service(get(not_found));
|
|
20
19
|
|
|
21
20
|
// Start listening on the given address.
|
|
22
21
|
let addr = SocketAddr::from(([127, 0, 0, 1], 3000));
|