From f25d37318e7873bf4f5ca58bcb850bed70ae77a6 Mon Sep 17 00:00:00 2001 From: Akshay Date: Wed, 16 Dec 2020 20:00:42 +0530 Subject: add product/ endpoints --- src/bin/server.rs | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) (limited to 'src/bin') diff --git a/src/bin/server.rs b/src/bin/server.rs index 180c5bc..601d514 100644 --- a/src/bin/server.rs +++ b/src/bin/server.rs @@ -5,7 +5,7 @@ use actix_web::{web, App, HttpServer}; use diesel::r2d2::{ConnectionManager, Pool}; use diesel::MysqlConnection; use furby::handlers::smoke::manual_hello; -use furby::handlers::{product, users}; +use furby::handlers::{cart_items, product, users}; use rand::Rng; #[actix_web::main] @@ -42,13 +42,26 @@ async fn main() -> std::io::Result<()> { ) .service( web::scope("/product") - .route("/{id}", web::get().to(product::product_details)) + .route("/catalog", web::get().to(product::get_all_products)) .route("/new", web::post().to(product::new_product)) + .route("/{id}", web::get().to(product::product_details)) .route( "/update_product/{id}", web::post().to(product::update_product), ), ) + .service( + web::scope("/cart") + .route( + "/items", + web::get().to(cart_items::get_user_cart_items), + ) + .route("/add", web::post().to(cart_items::add_to_cart)) + .route( + "/remove", + web::post().to(cart_items::remove_from_cart), + ), + ) .route("/hey", web::get().to(manual_hello)) }) .bind("127.0.0.1:7878")? -- cgit v1.2.3