diff --git a/README.md b/README.md index 14de5f5..0a33450 100644 --- a/README.md +++ b/README.md @@ -1 +1,23 @@ -# stacker \ No newline at end of file +# stacker + + +Run db migration +``` +sqlx migrate run + +``` + +Down migration + +``` +sqlx migrate revert +``` + + +Add rating + +``` + + curl -vX POST 'http://localhost:8000/rating' -d '{"obj_id": 111, "category": "application", "comment":"some comment", "rate": 10}' --header 'Content-Type: application/json' + +``` \ No newline at end of file diff --git a/src/routes/mod.rs b/src/routes/mod.rs index ad99270..9416275 100644 --- a/src/routes/mod.rs +++ b/src/routes/mod.rs @@ -1,10 +1,5 @@ -mod get_stack; mod health_checks; -// mod add_stack; -// mod deploy; mod rating; -// pub use get_stack::*; pub use health_checks::*; -// pub use add_stack::*; -// crate::routes:: +pub use rating::*; diff --git a/src/routes/rating.rs b/src/routes/rating.rs index 871f255..8e2b2ab 100644 --- a/src/routes/rating.rs +++ b/src/routes/rating.rs @@ -1,10 +1,21 @@ -use actix_web::HttpResponse; +use actix_web::{web, HttpResponse}; +use serde::{Deserialize, Serialize}; + // workflow // add, update, list, get(user_id), ACL, // ACL - access to func for a user // ACL - access to objects for a user -pub async fn rating() -> HttpResponse { - unimplemented!() +#[derive(Serialize, Deserialize, Debug)] +pub struct RatingForm { + pub obj_id: u32, // product external id + pub category: String, // rating of product | rating of service etc + pub comment: String, // always linked to a product + pub rate: u32, // +} + +pub async fn rating(form: web::Json) -> HttpResponse { + println!("{:?}", form); + HttpResponse::Ok().finish() } diff --git a/src/startup.rs b/src/startup.rs index 74a0e46..747922b 100644 --- a/src/startup.rs +++ b/src/startup.rs @@ -20,24 +20,9 @@ pub fn run(listener: TcpListener, db_pool: PgPool) -> Result