zero2prod_axum/src/startup.rs

17 lines
431 B
Rust
Raw Normal View History

2023-12-30 22:21:57 +01:00
use axum::routing::IntoMakeService;
use axum::serve::Serve;
use axum::Router;
use tokio::net::TcpListener;
/// API routing
pub fn app() -> Router {
Router::new()
.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())
}