Merge pull request #383 from ttys3/axum_example_v0.4.2

Axum example: update to Axum v0.4.2
This commit is contained in:
Chris Tsang 2021-12-15 13:50:34 +08:00 committed by GitHub
commit 4bcc8a24a2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 10 additions and 11 deletions

View File

@ -9,11 +9,11 @@ publish = false
[workspace]
[dependencies]
tokio = { version = "1.5", features = ["full"] }
axum = { version = "0.3.0" }
tower = "0.4.10"
tower-http = { version = "0.1", features = ["fs"] }
tower-cookies = { version = "0.3" }
tokio = { version = "1.14", features = ["full"] }
axum = { version = "0.4.2" }
tower = "0.4.11"
tower-http = { version = "0.2", features = ["fs"] }
tower-cookies = { version = "0.4" }
anyhow = "1"
dotenv = "0.15"
env_logger = "0.9"
@ -23,7 +23,7 @@ tera = "1"
[dependencies.sea-orm]
path = "../../" # remove this line in your own project
version = "^0.4.0"
version = "^0.4.2"
features = ["macros", "runtime-tokio-native-tls"]
default-features = false

View File

@ -3,11 +3,10 @@ mod post;
mod setup;
use axum::{
error_handling::HandleErrorExt,
extract::{Extension, Form, Path, Query},
http::StatusCode,
response::Html,
routing::{get, post, service_method_routing},
routing::{get, post, get_service},
AddExtensionLayer, Router, Server,
};
use flash::{get_flash_cookie, post_response, PostResponse};
@ -47,11 +46,11 @@ async fn main() -> anyhow::Result<()> {
.route("/delete/:id", post(delete_post))
.nest(
"/static",
service_method_routing::get(ServeDir::new(concat!(
get_service(ServeDir::new(concat!(
env!("CARGO_MANIFEST_DIR"),
"/static"
)))
.handle_error(|error: std::io::Error| {
.handle_error(|error: std::io::Error| async move {
(
StatusCode::INTERNAL_SERVER_ERROR,
format!("Unhandled internal error: {}", error),