refactor: changes
This commit is contained in:
parent
476eed4559
commit
f4deaceb27
7 changed files with 137 additions and 12 deletions
|
|
@ -1,16 +1,18 @@
|
|||
use axum::routing::IntoMakeService;
|
||||
use axum::serve::Serve;
|
||||
use axum::Router;
|
||||
use sqlx::PgPool;
|
||||
use tokio::net::TcpListener;
|
||||
|
||||
/// API routing
|
||||
pub fn app() -> Router {
|
||||
pub fn app(connection: PgPool) -> Router {
|
||||
Router::new()
|
||||
.with_state(connection)
|
||||
.merge(crate::routes::routes_health_check())
|
||||
.merge(crate::routes::routes_subscriptions())
|
||||
}
|
||||
|
||||
/// Start the server
|
||||
pub fn run(listener: TcpListener) -> Serve<IntoMakeService<Router>, Router> {
|
||||
axum::serve(listener, app().into_make_service())
|
||||
pub fn run(listener: TcpListener, connection: PgPool) -> Serve<IntoMakeService<Router>, Router> {
|
||||
axum::serve(listener, app(connection).into_make_service())
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue