17 lines
515 B
Rust
17 lines
515 B
Rust
use axum::routing::IntoMakeService;
|
|
use axum::serve::Serve;
|
|
use axum::Router;
|
|
use sqlx::PgPool;
|
|
use tokio::net::TcpListener;
|
|
|
|
/// API routing
|
|
pub fn app(connection: PgPool) -> Router {
|
|
Router::new()
|
|
.merge(crate::routes::routes_health_check())
|
|
.merge(crate::routes::routes_subscriptions(connection.clone()))
|
|
}
|
|
|
|
/// Start the server
|
|
pub fn run(listener: TcpListener, connection: PgPool) -> Serve<IntoMakeService<Router>, Router> {
|
|
axum::serve(listener, app(connection).into_make_service())
|
|
}
|