Run cargo fmt

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2022-12-22 19:35:17 +05:30
parent 55319a84da
commit 62b3c30a48
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -1,10 +1,15 @@
use actix_web::{get, App, HttpResponse, HttpServer, Responder, web::{Data, Query}, http::header::ContentType};
use actix_files as fs;
use tera::{Tera, Context};
use serde::{Serialize, Deserialize};
use reqwest::{Client, header::HeaderMap};
use std::env;
use actix_web::{
get,
http::header::ContentType,
web::{Data, Query},
App, HttpResponse, HttpServer, Responder,
};
use mime::TEXT_HTML;
use reqwest::{header::HeaderMap, Client};
use serde::{Deserialize, Serialize};
use std::env;
use tera::{Context, Tera};
struct Template {
paste: Tera,
@ -45,23 +50,23 @@ async fn paste_render(data: Data<Template>, paste: Query<Paste>) -> impl Respond
let response_json = response.text().await.unwrap();
if response_code != "200" {
paste_content = "Paste ID Invalid".to_string();
} else {
let resp_struct: ResponseJSON = serde_json::from_str(&response_json).unwrap();
paste_content =
String::from_utf8(base64::decode(resp_struct.content).unwrap()).unwrap();
}
else {
let resp_struct: ResponseJSON = serde_json::from_str(&response_json).unwrap();
paste_content = String::from_utf8(base64::decode(resp_struct.content).unwrap()).unwrap();
}
}
else {
} else {
paste_content = "Provide a Paste ID".to_string();
}
context.insert("paste_content", &paste_content);
let rendered = my_data.paste.render("paste.html", &context);
HttpResponse::Ok().insert_header(ContentType(TEXT_HTML)).body(rendered.unwrap())
HttpResponse::Ok()
.insert_header(ContentType(TEXT_HTML))
.body(rendered.unwrap())
}
#[actix_web::main]
async fn main() -> std::io::Result<()> {
let tera = match Tera::new("templates/*.html") {
Ok(t) => t,
Err(e) => {