Merge pull request #383 from ttys3/axum_example_v0.4.2
Axum example: update to Axum v0.4.2
This commit is contained in:
commit
4bcc8a24a2
@ -9,11 +9,11 @@ publish = false
|
|||||||
[workspace]
|
[workspace]
|
||||||
|
|
||||||
[dependencies]
|
[dependencies]
|
||||||
tokio = { version = "1.5", features = ["full"] }
|
tokio = { version = "1.14", features = ["full"] }
|
||||||
axum = { version = "0.3.0" }
|
axum = { version = "0.4.2" }
|
||||||
tower = "0.4.10"
|
tower = "0.4.11"
|
||||||
tower-http = { version = "0.1", features = ["fs"] }
|
tower-http = { version = "0.2", features = ["fs"] }
|
||||||
tower-cookies = { version = "0.3" }
|
tower-cookies = { version = "0.4" }
|
||||||
anyhow = "1"
|
anyhow = "1"
|
||||||
dotenv = "0.15"
|
dotenv = "0.15"
|
||||||
env_logger = "0.9"
|
env_logger = "0.9"
|
||||||
@ -23,7 +23,7 @@ tera = "1"
|
|||||||
|
|
||||||
[dependencies.sea-orm]
|
[dependencies.sea-orm]
|
||||||
path = "../../" # remove this line in your own project
|
path = "../../" # remove this line in your own project
|
||||||
version = "^0.4.0"
|
version = "^0.4.2"
|
||||||
features = ["macros", "runtime-tokio-native-tls"]
|
features = ["macros", "runtime-tokio-native-tls"]
|
||||||
default-features = false
|
default-features = false
|
||||||
|
|
||||||
|
@ -3,11 +3,10 @@ mod post;
|
|||||||
mod setup;
|
mod setup;
|
||||||
|
|
||||||
use axum::{
|
use axum::{
|
||||||
error_handling::HandleErrorExt,
|
|
||||||
extract::{Extension, Form, Path, Query},
|
extract::{Extension, Form, Path, Query},
|
||||||
http::StatusCode,
|
http::StatusCode,
|
||||||
response::Html,
|
response::Html,
|
||||||
routing::{get, post, service_method_routing},
|
routing::{get, post, get_service},
|
||||||
AddExtensionLayer, Router, Server,
|
AddExtensionLayer, Router, Server,
|
||||||
};
|
};
|
||||||
use flash::{get_flash_cookie, post_response, PostResponse};
|
use flash::{get_flash_cookie, post_response, PostResponse};
|
||||||
@ -47,11 +46,11 @@ async fn main() -> anyhow::Result<()> {
|
|||||||
.route("/delete/:id", post(delete_post))
|
.route("/delete/:id", post(delete_post))
|
||||||
.nest(
|
.nest(
|
||||||
"/static",
|
"/static",
|
||||||
service_method_routing::get(ServeDir::new(concat!(
|
get_service(ServeDir::new(concat!(
|
||||||
env!("CARGO_MANIFEST_DIR"),
|
env!("CARGO_MANIFEST_DIR"),
|
||||||
"/static"
|
"/static"
|
||||||
)))
|
)))
|
||||||
.handle_error(|error: std::io::Error| {
|
.handle_error(|error: std::io::Error| async move {
|
||||||
(
|
(
|
||||||
StatusCode::INTERNAL_SERVER_ERROR,
|
StatusCode::INTERNAL_SERVER_ERROR,
|
||||||
format!("Unhandled internal error: {}", error),
|
format!("Unhandled internal error: {}", error),
|
||||||
|
Loading…
x
Reference in New Issue
Block a user