diff options
author | Akshay <[email protected]> | 2020-12-16 14:30:42 +0000 |
---|---|---|
committer | Akshay <[email protected]> | 2020-12-16 14:30:42 +0000 |
commit | f25d37318e7873bf4f5ca58bcb850bed70ae77a6 (patch) | |
tree | 3a470f463d274f31228c71eb793a912f06b09046 /src/bin | |
parent | 199f6bfd503901121b0cdf532a46de89b592ada0 (diff) |
add product/ endpoints
Diffstat (limited to 'src/bin')
-rw-r--r-- | src/bin/server.rs | 17 |
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}; | |||
5 | use diesel::r2d2::{ConnectionManager, Pool}; | 5 | use diesel::r2d2::{ConnectionManager, Pool}; |
6 | use diesel::MysqlConnection; | 6 | use diesel::MysqlConnection; |
7 | use furby::handlers::smoke::manual_hello; | 7 | use furby::handlers::smoke::manual_hello; |
8 | use furby::handlers::{product, users}; | 8 | use furby::handlers::{cart_items, product, users}; |
9 | use rand::Rng; | 9 | use 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")? |