aboutsummaryrefslogtreecommitdiff
path: root/src/bin
diff options
context:
space:
mode:
authorAkshay <[email protected]>2020-12-16 14:30:42 +0000
committerAkshay <[email protected]>2020-12-16 14:30:42 +0000
commitf25d37318e7873bf4f5ca58bcb850bed70ae77a6 (patch)
tree3a470f463d274f31228c71eb793a912f06b09046 /src/bin
parent199f6bfd503901121b0cdf532a46de89b592ada0 (diff)
add product/ endpoints
Diffstat (limited to 'src/bin')
-rw-r--r--src/bin/server.rs17
1 files changed, 15 insertions, 2 deletions
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};
5use diesel::r2d2::{ConnectionManager, Pool}; 5use diesel::r2d2::{ConnectionManager, Pool};
6use diesel::MysqlConnection; 6use diesel::MysqlConnection;
7use furby::handlers::smoke::manual_hello; 7use furby::handlers::smoke::manual_hello;
8use furby::handlers::{product, users}; 8use furby::handlers::{cart_items, product, users};
9use rand::Rng; 9use rand::Rng;
10 10
11#[actix_web::main] 11#[actix_web::main]
@@ -42,13 +42,26 @@ async fn main() -> std::io::Result<()> {
42 ) 42 )
43 .service( 43 .service(
44 web::scope("/product") 44 web::scope("/product")
45 .route("/{id}", web::get().to(product::product_details)) 45 .route("/catalog", web::get().to(product::get_all_products))
46 .route("/new", web::post().to(product::new_product)) 46 .route("/new", web::post().to(product::new_product))
47 .route("/{id}", web::get().to(product::product_details))
47 .route( 48 .route(
48 "/update_product/{id}", 49 "/update_product/{id}",
49 web::post().to(product::update_product), 50 web::post().to(product::update_product),
50 ), 51 ),
51 ) 52 )
53 .service(
54 web::scope("/cart")
55 .route(
56 "/items",
57 web::get().to(cart_items::get_user_cart_items),
58 )
59 .route("/add", web::post().to(cart_items::add_to_cart))
60 .route(
61 "/remove",
62 web::post().to(cart_items::remove_from_cart),
63 ),
64 )
52 .route("/hey", web::get().to(manual_hello)) 65 .route("/hey", web::get().to(manual_hello))
53 }) 66 })
54 .bind("127.0.0.1:7878")? 67 .bind("127.0.0.1:7878")?