Use base64::Engine instead of base64::decode

Signed-off-by: baalajimaestro <me@baalajimaestro.me>
This commit is contained in:
baalajimaestro 2023-02-21 12:52:14 +05:30
parent 4f2c282695
commit 3c8aee3c09
Signed by: baalajimaestro
GPG key ID: F93C394FE9BBAFD5

View file

@ -8,6 +8,7 @@ use actix_web::{
use mime::TEXT_HTML;
use reqwest::{header::HeaderMap, Client};
use serde::{Deserialize, Serialize};
use base64::{Engine, engine::general_purpose};
use std::env;
use tera::{Context, Tera};
@ -53,8 +54,7 @@ async fn paste_render(data: Data<Template>, paste: Query<Paste>) -> impl Respond
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();
paste_content = String::from_utf8(general_purpose::STANDARD.decode(resp_struct.content).unwrap()).unwrap();
}
} else {
paste_content = "Provide a Paste ID".to_string();