From 048dcb64d22b4aa27339126f25d61d1eee1d7654 Mon Sep 17 00:00:00 2001 From: Yukiteru Li Date: Tue, 9 Jan 2024 20:52:09 +0800 Subject: [PATCH 1/2] chore(volo-http): add `prelude` module (#323) Signed-off-by: Yu Li --- Cargo.lock | 2 +- volo-http/Cargo.toml | 2 +- volo-http/src/lib.rs | 51 ++++++++++++++++++++++++-------------------- 3 files changed, 30 insertions(+), 25 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index dfdff1e2..b3969755 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2997,7 +2997,7 @@ dependencies = [ [[package]] name = "volo-http" -version = "0.1.9" +version = "0.1.10" dependencies = [ "bytes", "cookie", diff --git a/volo-http/Cargo.toml b/volo-http/Cargo.toml index 8450ba3b..1db15481 100644 --- a/volo-http/Cargo.toml +++ b/volo-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "volo-http" -version = "0.1.9" +version = "0.1.10" edition.workspace = true homepage.workspace = true repository.workspace = true diff --git a/volo-http/src/lib.rs b/volo-http/src/lib.rs index 13dc0c74..e7b1a4f0 100644 --- a/volo-http/src/lib.rs +++ b/volo-http/src/lib.rs @@ -13,33 +13,38 @@ pub mod request; pub mod response; pub mod route; pub mod server; + pub(crate) mod service_fn; mod macros; -use std::convert::Infallible; +#[doc(hidden)] +mod prelude { + pub use bytes::Bytes; + pub use hyper::{ + self, + body::Incoming as BodyIncoming, + http::{self, HeaderMap, HeaderName, HeaderValue, Method, StatusCode, Uri, Version}, + }; + pub use volo::net::Address; -pub use bytes::Bytes; -pub use hyper::{ - self, - body::Incoming as BodyIncoming, - http::{self, HeaderMap, HeaderName, HeaderValue, Method, StatusCode, Uri, Version}, -}; -pub use volo::net::Address; + #[cfg(feature = "cookie")] + pub use crate::cookie::CookieJar; + #[cfg(any(feature = "serde_json", feature = "sonic_json"))] + pub use crate::json::Json; + pub use crate::{ + context::{ConnectionInfo, HttpContext}, + extension::Extension, + extract::{Form, MaybeInvalid, Query, State}, + param::Params, + request::Request, + response::Response, + route::Router, + server::Server, + }; -#[cfg(feature = "cookie")] -pub use crate::cookie::CookieJar; -#[cfg(any(feature = "serde_json", feature = "sonic_json"))] -pub use crate::json::Json; -pub use crate::{ - context::{ConnectionInfo, HttpContext}, - extension::Extension, - extract::{Form, MaybeInvalid, Query, State}, - param::Params, - request::Request, - response::Response, - route::Router, - server::Server, -}; + pub type DynService = + motore::BoxCloneService; +} -pub type DynService = motore::BoxCloneService; +pub use prelude::*; From b92527f776c5befb89a76ad131e9a7bbde472daf Mon Sep 17 00:00:00 2001 From: Yukiteru Li Date: Tue, 9 Jan 2024 20:58:17 +0800 Subject: [PATCH 2/2] chore(volo-http): make `prelude` public (#324) Signed-off-by: Yu Li --- Cargo.lock | 2 +- volo-http/Cargo.toml | 2 +- volo-http/src/lib.rs | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index b3969755..74d3bdba 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -2997,7 +2997,7 @@ dependencies = [ [[package]] name = "volo-http" -version = "0.1.10" +version = "0.1.11" dependencies = [ "bytes", "cookie", diff --git a/volo-http/Cargo.toml b/volo-http/Cargo.toml index 1db15481..fa8f8a1a 100644 --- a/volo-http/Cargo.toml +++ b/volo-http/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "volo-http" -version = "0.1.10" +version = "0.1.11" edition.workspace = true homepage.workspace = true repository.workspace = true diff --git a/volo-http/src/lib.rs b/volo-http/src/lib.rs index e7b1a4f0..93ea4431 100644 --- a/volo-http/src/lib.rs +++ b/volo-http/src/lib.rs @@ -19,7 +19,7 @@ pub(crate) mod service_fn; mod macros; #[doc(hidden)] -mod prelude { +pub mod prelude { pub use bytes::Bytes; pub use hyper::{ self,