Skip to content

Commit

Permalink
feat!: Update to axum 0.7.2
Browse files Browse the repository at this point in the history
  • Loading branch information
lu-zero committed Dec 26, 2023
1 parent 219ee52 commit 00cc15e
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 14 deletions.
5 changes: 3 additions & 2 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -13,12 +13,13 @@ mdns-sd = "0.10.1"
thiserror = "1.0"
if-addrs = "0.10.1"
hostname = "0.3"
axum = "0.6.10"
axum = "0.7.2"
serde = "1.0.141"
serde_json = "1.0.83"
uuid = { version = "1.1.2", features = ["v4"] }
datta = "0.1"
tower-http = { version = "0.4.0", features = ["cors"] }
tower-http = { version = "0.5.0", features = ["cors"] }
tokio = { version = "1.20.1", features = ["net"] }

[dev-dependencies]
tokio = { version = "1.20.1", features = ["macros", "rt-multi-thread"] }
Expand Down
6 changes: 4 additions & 2 deletions src/servient.rs
Original file line number Diff line number Diff line change
Expand Up @@ -119,8 +119,10 @@ impl<O: ExtendableThing> Servient<O> {
.port(self.http_addr.port())
.build()?;

axum::Server::bind(&self.http_addr)
.serve(self.router.clone().into_make_service())
let listener = tokio::net::TcpListener::bind(&self.http_addr)
.await
.map_err(axum::Error::new)?;
axum::serve(listener, self.router.clone())
.await
.map_err(axum::Error::new)?;

Expand Down
20 changes: 10 additions & 10 deletions src/servient/builder.rs
Original file line number Diff line number Diff line change
Expand Up @@ -249,27 +249,27 @@ pub trait HttpRouter {
/// Route GET requests to the given handler.
fn http_get<H, T>(self, handler: H) -> Self::Target
where
H: Handler<T, (), axum::body::Body>,
H: Handler<T, ()>,
T: 'static;
/// Route PUT requests to the given handler.
fn http_put<H, T>(self, handler: H) -> Self::Target
where
H: Handler<T, (), axum::body::Body>,
H: Handler<T, ()>,
T: 'static;
/// Route POST requests to the given handler.
fn http_post<H, T>(self, handler: H) -> Self::Target
where
H: Handler<T, (), axum::body::Body>,
H: Handler<T, ()>,
T: 'static;
/// Route PATCH requests to the given handler.
fn http_patch<H, T>(self, handler: H) -> Self::Target
where
H: Handler<T, (), axum::body::Body>,
H: Handler<T, ()>,
T: 'static;
/// Route DELETE requests to the given handler.
fn http_delete<H, T>(self, handler: H) -> Self::Target
where
H: Handler<T, (), axum::body::Body>,
H: Handler<T, ()>,
T: 'static;
}

Expand Down Expand Up @@ -375,7 +375,7 @@ where
/// Route GET requests to the given handler.
fn http_get<H, T>(mut self, handler: H) -> Self::Target
where
H: Handler<T, (), axum::body::Body>,
H: Handler<T, ()>,
T: 'static,
{
let method_router = std::mem::take(&mut self.other.field_mut().method_router);
Expand All @@ -387,7 +387,7 @@ where
/// Route PUT requests to the given handler.
fn http_put<H, T>(mut self, handler: H) -> Self::Target
where
H: Handler<T, (), axum::body::Body>,
H: Handler<T, ()>,
T: 'static,
{
let method_router = std::mem::take(&mut self.other.field_mut().method_router);
Expand All @@ -399,7 +399,7 @@ where
/// Route POST requests to the given handler.
fn http_post<H, T>(mut self, handler: H) -> Self::Target
where
H: Handler<T, (), axum::body::Body>,
H: Handler<T, ()>,
T: 'static,
{
let method_router = std::mem::take(&mut self.other.field_mut().method_router);
Expand All @@ -411,7 +411,7 @@ where
/// Route PATCH requests to the given handler.
fn http_patch<H, T>(mut self, handler: H) -> Self::Target
where
H: Handler<T, (), axum::body::Body>,
H: Handler<T, ()>,
T: 'static,
{
let method_router = std::mem::take(&mut self.other.field_mut().method_router);
Expand All @@ -423,7 +423,7 @@ where
/// Route DELETE requests to the given handler.
fn http_delete<H, T>(mut self, handler: H) -> Self::Target
where
H: Handler<T, (), axum::body::Body>,
H: Handler<T, ()>,
T: 'static,
{
let method_router = std::mem::take(&mut self.other.field_mut().method_router);
Expand Down

0 comments on commit 00cc15e

Please sign in to comment.