fmt and use new render_error! macro

master
rascul 2 years ago
parent b5c6ad1309
commit bbb1bf0723

@ -2,20 +2,22 @@ use actix_multipart::Multipart;
use actix_web::{post, web, Error, HttpResponse};
use handlebars::Handlebars;
use serde_json::to_string_pretty;
use serde_json::{json, to_string_pretty};
use crate::render_error;
use crate::WotLog;
#[post("/submit")]
pub async fn post(
payload: Multipart,
_hb: web::Data<Handlebars<'_>>,
hb: web::Data<Handlebars<'_>>,
) -> Result<HttpResponse, Error> {
let mut wotlog = WotLog::from_payload(payload).await?;
wotlog.parse_log()?;
wotlog.save()?;
let mut wotlog = render_error!(hb, WotLog::from_payload(payload).await);
let body = format!("{}", to_string_pretty(&wotlog.json)?);
render_error!(hb, wotlog.parse_log());
render_error!(hb, wotlog.save());
let body = format!("{}", render_error!(hb, to_string_pretty(&wotlog.json)));
Ok(HttpResponse::Ok().body(body))
}

Loading…
Cancel
Save