diff --git a/Cargo.toml b/Cargo.toml index c7c52da380..78fe0afd28 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -36,3 +36,7 @@ chrono = { version = "0.4.19", default-features = false } bytes = "1.1.0" futures-util = "0.3.17" tokio-stream = "0.1.8" +serde_yaml = "0.9" +quick-xml = { version = "=0.26.0", features = ["serialize"] } # https://github.com/tafia/quick-xml/issues/540 +base64 = "0.21.0" +serde_urlencoded = "0.7.1" \ No newline at end of file diff --git a/examples/poem/tera-templating/Cargo.toml b/examples/poem/tera-templating/Cargo.toml index 6e4c282b21..934aeeb3b1 100644 --- a/examples/poem/tera-templating/Cargo.toml +++ b/examples/poem/tera-templating/Cargo.toml @@ -5,7 +5,7 @@ edition.workspace = true publish.workspace = true [dependencies] -poem = { workspace = true, features = ["rustls"]} +poem.workspace = true tokio = { workspace = true, features = ["full"] } tera = "1.17.1" -lazy_static = "1.4.0" +once_cell = "1.17.0" diff --git a/examples/poem/tera-templating/src/main.rs b/examples/poem/tera-templating/src/main.rs index 6ec3d0d78c..b5ce0e3ac6 100644 --- a/examples/poem/tera-templating/src/main.rs +++ b/examples/poem/tera-templating/src/main.rs @@ -1,3 +1,4 @@ +use once_cell::sync::Lazy; use poem::{ error::InternalServerError, get, handler, @@ -7,22 +8,17 @@ use poem::{ }; use tera::{Context, Tera}; -#[macro_use] -extern crate lazy_static; - -lazy_static! { - pub static ref TEMPLATES: Tera = { - let mut tera = match Tera::new("templates/**/*") { - Ok(t) => t, - Err(e) => { - println!("Parsing error(s): {e}"); - ::std::process::exit(1); - } - }; - tera.autoescape_on(vec![".html", ".sql"]); - tera +static TEMPLATES: Lazy = Lazy::new(|| { + let mut tera = match Tera::new("templates/**/*") { + Ok(t) => t, + Err(e) => { + println!("Parsing error(s): {e}"); + ::std::process::exit(1); + } }; -} + tera.autoescape_on(vec![".html", ".sql"]); + tera +}); #[handler] fn hello(Path(name): Path) -> Result, poem::Error> { diff --git a/poem-openapi-derive/src/multipart.rs b/poem-openapi-derive/src/multipart.rs index d518f18df5..7bfe40e950 100644 --- a/poem-openapi-derive/src/multipart.rs +++ b/poem-openapi-derive/src/multipart.rs @@ -1,6 +1,7 @@ use std::str::FromStr; use darling::{ast::Data, util::Ignored, FromDeriveInput, FromField}; +use mime as _; use proc_macro2::{Ident, TokenStream}; use quote::quote; use syn::{ext::IdentExt, Attribute, DeriveInput, Error, Generics, Type}; diff --git a/poem-openapi/Cargo.toml b/poem-openapi/Cargo.toml index ac6df9ad91..6fbb0e0196 100644 --- a/poem-openapi/Cargo.toml +++ b/poem-openapi/Cargo.toml @@ -36,10 +36,10 @@ poem = { workspace = true, default_features = true, features = [ tokio = { workspace = true, features = ["fs"] } serde_json.workspace = true -serde_yaml = "0.9.0" -quick-xml = { version = "0.27.1", features = ["serialize"] } -serde_urlencoded = "0.7.1" -base64 = "0.21.0" +serde_yaml.workspace = true +quick-xml.workspace = true +serde_urlencoded.workspace = true +base64.workspace = true serde.workspace = true derive_more = "0.99.16" num-traits = "0.2.14" diff --git a/poem/Cargo.toml b/poem/Cargo.toml index b9b0e12769..cfbb3ba17b 100644 --- a/poem/Cargo.toml +++ b/poem/Cargo.toml @@ -27,7 +27,7 @@ multipart = ["multer"] rustls = ["server", "tokio-rustls", "rustls-pemfile"] native-tls = ["server", "tokio-native-tls"] openssl-tls = ["server", "tokio-openssl", "openssl"] -sse = [] +sse = ["tokio-stream"] static-files = ["httpdate", "mime_guess", "tokio/io-util", "tokio/fs"] compression = ["async-compression"] tower-compat = ["tokio/rt", "tower"] @@ -77,8 +77,7 @@ tokio = { workspace = true, features = ["sync", "time", "macros", "net"] } tokio-util = { version = "0.7.0", features = ["io"] } serde.workspace = true serde_json.workspace = true -serde_urlencoded = "0.7.0" -tokio-stream.workspace = true +serde_urlencoded.workspace = true parking_lot = "0.12.0" pin-project-lite = "0.2.7" percent-encoding = "2.1.0" @@ -135,7 +134,7 @@ priority-queue = { version = "1.2.0", optional = true } tokio-native-tls = { version = "0.3.0", optional = true } tokio-openssl = { version = "0.6.3", optional = true } openssl = { version = "0.10", optional = true } -base64 = { version = "0.21.0", optional = true } +base64 = { workspace = true, optional = true } libcsrf = { package = "csrf", version = "0.4.1", optional = true } httpdate = { version = "1.0.2", optional = true } sse-codec = { version = "0.3.2", optional = true } @@ -151,8 +150,9 @@ x509-parser = { version = "0.14.0", optional = true } tokio-metrics = { version = "0.1.0", optional = true } rust-embed = { version = "6.3", optional = true } hex = { version = "0.4", optional = true } -quick-xml = { version = "0.26.0", optional = true, features = ["serialize"] } -serde_yaml = { version = "0.9", optional = true } +quick-xml = { workspace = true, optional = true } +serde_yaml = { workspace = true, optional = true } +tokio-stream = { workspace = true, optional = true } # Feature optional dependencies anyhow = { version = "1.0.0", optional = true } diff --git a/poem/src/session/redis_storage.rs b/poem/src/session/redis_storage.rs index ea1f6d6d23..70879c7d46 100644 --- a/poem/src/session/redis_storage.rs +++ b/poem/src/session/redis_storage.rs @@ -86,7 +86,6 @@ mod tests { }; if !client.check_connection() { panic!("redis server is not running"); - return; } let app = Route::new().at("/:action", index).with(ServerSession::new(