Skip to content

Commit

Permalink
feat: remove syncwrapper from axum integration
Browse files Browse the repository at this point in the history
  • Loading branch information
oddgrd committed Mar 3, 2023
1 parent bbe3cb7 commit 791c034
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 10 deletions.
1 change: 0 additions & 1 deletion Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

3 changes: 1 addition & 2 deletions service/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,6 @@ salvo = { version = "0.37.5", optional = true }
serde_json = { workspace = true }
serenity = { version = "0.11.5", default-features = false, features = ["client", "gateway", "rustls_backend", "model"], optional = true }
poise = { version = "0.5.2", optional = true }
sync_wrapper = { version = "0.1.1", optional = true }
thiserror = { workspace = true }
thruster = { version = "1.3.0", optional = true }
tide = { version = "0.16.0", optional = true }
Expand Down Expand Up @@ -70,7 +69,7 @@ codegen = ["shuttle-codegen/frameworks"]
loader = ["cargo", "libloading"]

web-actix-web = ["actix-web", "num_cpus"]
web-axum = ["axum", "sync_wrapper"]
web-axum = ["axum"]
web-rocket = ["rocket"]
web-thruster = ["thruster"]
web-tide = ["tide", "async-std"]
Expand Down
12 changes: 5 additions & 7 deletions service/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -540,19 +540,20 @@ pub type ShuttleWarp<T> = Result<warp::filters::BoxedFilter<T>, Error>;

#[cfg(feature = "web-axum")]
#[async_trait]
impl Service for sync_wrapper::SyncWrapper<axum::Router> {
impl Service for axum::Router {
async fn bind(mut self, addr: SocketAddr) -> Result<(), error::Error> {
let router = self.into_inner();

axum::Server::bind(&addr)
.serve(router.into_make_service())
.serve(self.into_make_service())
.await
.map_err(error::CustomError::new)?;

Ok(())
}
}

#[cfg(feature = "web-axum")]
pub type ShuttleAxum = Result<axum::Router, Error>;

#[cfg(feature = "web-actix-web")]
#[async_trait]
impl<F> Service for F
Expand All @@ -575,9 +576,6 @@ where
#[cfg(feature = "web-actix-web")]
pub type ShuttleActixWeb<F> = Result<F, Error>;

#[cfg(feature = "web-axum")]
pub type ShuttleAxum = Result<sync_wrapper::SyncWrapper<axum::Router>, Error>;

#[cfg(feature = "web-salvo")]
#[async_trait]
impl Service for salvo::Router {
Expand Down

0 comments on commit 791c034

Please sign in to comment.