From 01d902d3118d482660664ac3b8c6a780a5cc8ed8 Mon Sep 17 00:00:00 2001 From: baalajimaestro Date: Sun, 11 Dec 2022 19:45:48 +0530 Subject: [PATCH] Deserialize paste json properly Signed-off-by: baalajimaestro --- Cargo.lock | 18 +++++++++++++----- Cargo.toml | 2 ++ src/main.rs | 33 ++++++++++++++++++++++++++++----- 3 files changed, 43 insertions(+), 10 deletions(-) diff --git a/Cargo.lock b/Cargo.lock index a185a89..e0b090c 100644 --- a/Cargo.lock +++ b/Cargo.lock @@ -7,8 +7,10 @@ name = "actix-backend" version = "0.1.0" dependencies = [ "actix-web", + "base64 0.20.0", "reqwest", "serde", + "serde_json", "tera", ] @@ -40,7 +42,7 @@ dependencies = [ "actix-service", "actix-utils", "ahash", - "base64", + "base64 0.13.1", "bitflags", "brotli", "bytes", @@ -253,6 +255,12 @@ version = "0.13.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "9e1b586273c5702936fe7b7d6896644d8be71e6314cfe09d3167c95f712589e8" +[[package]] +name = "base64" +version = "0.20.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0ea22880d78093b0cbe17c89f64a7d457941e65759157ec6cb31a31d652b05e5" + [[package]] name = "bitflags" version = "1.3.2" @@ -1189,7 +1197,7 @@ version = "0.11.13" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "68cc60575865c7831548863cc02356512e3f1dc2f3f82cb837d7fc4cc8f3c97c" dependencies = [ - "base64", + "base64 0.13.1", "bytes", "encoding_rs", "futures-core", @@ -1264,7 +1272,7 @@ version = "1.0.1" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "0864aeff53f8c05aa08d86e5ef839d3dfcf07aeba2db32f12db0ef716e87bd55" dependencies = [ - "base64", + "base64 0.13.1", ] [[package]] @@ -1332,9 +1340,9 @@ dependencies = [ [[package]] name = "serde_json" -version = "1.0.87" +version = "1.0.89" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6ce777b7b150d76b9cf60d28b55f5847135a003f7d7350c6be7a773508ce7d45" +checksum = "020ff22c755c2ed3f8cf162dbb41a7268d934702f3ed3631656ea597e08fc3db" dependencies = [ "itoa", "ryu", diff --git a/Cargo.toml b/Cargo.toml index f679c34..cbdd67f 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -10,3 +10,5 @@ actix-web = "4" tera = "1.17.1" serde = { version = "1.0", features = ["derive"] } reqwest = { version = "0.11", default-features = false, features = ["rustls-tls"] } +serde_json = "1.0.89" +base64 = "0.20.0" diff --git a/src/main.rs b/src/main.rs index 05f103d..a06f821 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,6 +1,6 @@ use actix_web::{get, App, HttpResponse, HttpServer, Responder, web::{Data, Query}}; use tera::{Tera, Context}; -use serde::Deserialize; +use serde::{Serialize, Deserialize}; use reqwest::{Client, header::HeaderMap}; struct Template { @@ -12,6 +12,20 @@ struct Paste { paste_id: Option, } +#[derive(Serialize, Deserialize)] +struct ResponseJSON { + file_name: String, + file_path: String, + size: u64, + encoding: String, + content_sha256: String, + r#ref: String, + blob_id: String, + commit_id: String, + last_commit_id: String, + execute_filemode: bool, + content: String, +} #[get("/")] async fn paste_render(data: Data