Skip to content

Commit

Permalink
feat(shuttle-axum) Make AxumService generic to be able to use axum::S…
Browse files Browse the repository at this point in the history
…tate with it (#924)
  • Loading branch information
morlinbrot authored May 25, 2023
1 parent 5b9885c commit e6ade25
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions services/shuttle-axum/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ use shuttle_runtime::{CustomError, Error};
use std::net::SocketAddr;

/// A wrapper type for [axum::Router] so we can implement [shuttle_runtime::Service] for it.
pub struct AxumService(pub axum::Router);
pub struct AxumService<S = ()>(pub axum::Router<S>);

#[shuttle_runtime::async_trait]
impl shuttle_runtime::Service for AxumService {
Expand All @@ -34,10 +34,11 @@ impl shuttle_runtime::Service for AxumService {
}
}

impl From<axum::Router> for AxumService {
fn from(router: axum::Router) -> Self {
impl<S> From<axum::Router<S>> for AxumService<S> {
fn from(router: axum::Router<S>) -> Self {
Self(router)
}
}

/// The return type that should be returned from the [shuttle_runtime::main] function.
pub type ShuttleAxum = Result<AxumService, Error>;

0 comments on commit e6ade25

Please sign in to comment.