1
0
mirror of https://github.com/actix/examples synced 2025-02-02 17:39:05 +01:00
examples/async_ex2/src/appconfig.rs

37 lines
1.5 KiB
Rust
Raw Normal View History

2019-04-09 14:12:07 -04:00
use actix_web::{error, web};
2019-04-14 10:34:41 -07:00
use crate::handlers::{parts, products};
2019-04-09 14:12:07 -04:00
2019-04-21 09:36:31 -07:00
pub fn config_app(cfg: &mut web::ServiceConfig) {
2019-04-09 14:12:07 -04:00
// domain includes: /products/{product_id}/parts/{part_id}
cfg.service(
web::scope("/products")
.service(
web::resource("")
.route(web::get().to_async(products::get_products))
2019-04-14 10:34:41 -07:00
.route(web::post().to_async(products::add_product)),
2019-04-09 14:12:07 -04:00
)
.service(
web::scope("/{product_id}")
.service(
web::resource("")
.route(web::get().to_async(products::get_product_detail))
2019-04-14 10:34:41 -07:00
.route(web::delete().to_async(products::remove_product)),
2019-04-09 14:12:07 -04:00
)
.service(
web::scope("/parts")
.service(
web::resource("")
.route(web::get().to_async(parts::get_parts))
2019-04-14 10:34:41 -07:00
.route(web::post().to_async(parts::add_part)),
2019-04-09 14:12:07 -04:00
)
.service(
web::resource("/{part_id}")
.route(web::get().to_async(parts::get_part_detail))
2019-04-14 10:34:41 -07:00
.route(web::delete().to_async(parts::remove_part)),
),
),
),
2019-04-09 14:12:07 -04:00
);
2019-04-14 10:34:41 -07:00
}