Beginning of frontend + recipe editing
(it's a mess)
This commit is contained in:
parent
642dd8a80c
commit
cbe276fc06
16 changed files with 203 additions and 63 deletions
|
|
@ -1,6 +1,8 @@
|
|||
use actix_web::{http::{header, header::ContentType, StatusCode}, get, post, put, web, Responder, HttpRequest, HttpResponse, cookie::Cookie};
|
||||
use actix_web::{http::{header, header::ContentType, StatusCode}, get, post, put, web, Responder, HttpRequest, HttpResponse, cookie::Cookie, HttpMessage};
|
||||
use chrono::Duration;
|
||||
use futures::TryFutureExt;
|
||||
use serde::Deserialize;
|
||||
use ron::de::from_bytes;
|
||||
use log::{debug, error, log_enabled, info, Level};
|
||||
|
||||
use super::Result;
|
||||
|
|
@ -11,17 +13,16 @@ use crate::user::User;
|
|||
use crate::model;
|
||||
use crate::data::{db, asynchronous};
|
||||
|
||||
#[put("/ron-api/set-title")]
|
||||
pub async fn set_title(req: HttpRequest, connection: web::Data<db::Connection>) -> Result<HttpResponse> {
|
||||
//req.app_config()
|
||||
let id = 1;
|
||||
let title = "XYZ".to_string();
|
||||
#[put("/ron-api/recipe/set-title")]
|
||||
pub async fn set_recipe_title(req: HttpRequest, body: web::Bytes, connection: web::Data<db::Connection>) -> Result<HttpResponse> {
|
||||
let ron_req: common::ron_api::SetRecipeTitle = from_bytes(&body)?;
|
||||
connection.set_recipe_title_async(ron_req.recipe_id, &ron_req.title).await?;
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
|
||||
//let recipes = connection.set_recipe_title_async(id, title).await?;
|
||||
|
||||
Ok(
|
||||
HttpResponse::Ok()
|
||||
.content_type("application/ron")
|
||||
.body("DATA")
|
||||
)
|
||||
#[put("/ron-api/recipe/set-description")]
|
||||
pub async fn set_recipe_description(req: HttpRequest, body: web::Bytes, connection: web::Data<db::Connection>) -> Result<HttpResponse> {
|
||||
let ron_req: common::ron_api::SetRecipeDescription = from_bytes(&body)?;
|
||||
connection.set_recipe_description_async(ron_req.recipe_id, &ron_req.description).await?;
|
||||
Ok(HttpResponse::Ok().finish())
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue