Reputation: 115
I have the following server declaration right now
let server = HttpServer::new(move || {
App::new()
.app_data(actix_web::web::Data::new(pool.clone()))
.service(ping)
.service(stock::controller::get_all)
.service(stock::controller::find_one)
.service(stock::controller::insert_one)
.service(stock::controller::insert_many)
})
.bind(("127.0.0.1", 7777))?
.run();
I feel like it will be very hard to control it when I'll add other routes. Is there a way to split it so I could have something like
App::new()
.app_data(actix_web::web::Data::new(pool.clone()))
.service(ping)
.service(stock::controller::routes)
And have the routes function add all the services declared in first code sample?
Upvotes: 4
Views: 2288