Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

chore(shuttle-axum): use axum 0.7 by default #1507

Merged
merged 5 commits into from
Jan 8, 2024
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .circleci/config.yml
Original file line number Diff line number Diff line change
Expand Up @@ -741,7 +741,7 @@ workflows:
- services/shuttle-axum
features:
- "-F axum"
- "-F axum-0-7 --no-default-features"
- "-F axum-0-6 --no-default-features"
- test-standalone:
# Has mutually exclusive features, so we run checks for each feature separately
name: "services/shuttle-serenity: << matrix.features >>"
Expand Down
6 changes: 3 additions & 3 deletions services/shuttle-axum/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@ keywords = ["shuttle-service", "axum"]
[workspace]

[dependencies]
axum = { version = "0.6.13", optional = true }
axum-0-7 = { package = "axum", version = "0.7.1", optional = true }
axum = { version = "0.7.3", optional = true }
axum-0-6 = { package = "axum", version = "0.6.13", optional = true }
shuttle-runtime = { path = "../../runtime", version = "0.35.1", default-features = false }

[dev-dependencies]
Expand All @@ -19,4 +19,4 @@ tokio = { version = "1.26.0", features = ["macros", "rt-multi-thread"] }
[features]
default = ["axum"]

axum-0-7 = ["dep:axum-0-7"]
axum-0-6 = ["dep:axum-0-6"]
11 changes: 7 additions & 4 deletions services/shuttle-axum/README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,12 @@
## Shuttle service integration for the Axum web framework.
## Shuttle service integration for the Axum web framework

Axum 0.7 is used by default.

Axum 0.6 is supported by using these feature flags:

Axum 0.7 is now supported by using these feature flags:
```toml,ignore
axum = "0.7.0"
shuttle-axum = { version = "0.35.1", default-features = false, features = ["axum-0-7"] }
axum = "0.6.0"
shuttle-axum = { version = "0.35.1", default-features = false, features = ["axum-0-6"] }
```

### Example
Expand Down
16 changes: 8 additions & 8 deletions services/shuttle-axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ use std::net::SocketAddr;

#[cfg(feature = "axum")]
use axum::Router;
#[cfg(feature = "axum-0-7")]
use axum_0_7::Router;
#[cfg(feature = "axum-0-6")]
use axum_0_6::Router;

/// A wrapper type for [axum::Router] so we can implement [shuttle_runtime::Service] for it.
pub struct AxumService(pub Router);
Expand All @@ -16,19 +16,19 @@ impl shuttle_runtime::Service for AxumService {
/// and binds to an address passed in by shuttle.
async fn bind(mut self, addr: SocketAddr) -> Result<(), Error> {
#[cfg(feature = "axum")]
axum::Server::bind(&addr)
.serve(self.0.into_make_service())
.await
.map_err(CustomError::new)?;
#[cfg(feature = "axum-0-7")]
axum_0_7::serve(
axum::serve(
shuttle_runtime::tokio::net::TcpListener::bind(addr)
.await
.map_err(CustomError::new)?,
self.0,
)
.await
.map_err(CustomError::new)?;
#[cfg(feature = "axum-0-6")]
axum_0_6::Server::bind(&addr)
.serve(self.0.into_make_service())
.await
.map_err(CustomError::new)?;

Ok(())
}
Expand Down