chg: Use json for sending url list

This commit is contained in:
SinTan1729
2024-03-31 15:38:59 -05:00
parent 99b5298cd8
commit f2b5e1ab6d
3 changed files with 24 additions and 24 deletions

View File

@@ -6,7 +6,6 @@ use rand::seq::SliceRandom;
use regex::Regex;
use rusqlite::Connection;
use serde::Deserialize;
use serde_json::from_str;
#[derive(Deserialize)]
struct Url {
@@ -29,11 +28,11 @@ fn validate_link(link: &str) -> bool {
pub fn getall(db: &Connection) -> String {
let links = database::getall(db);
links.join("\n")
serde_json::to_string(&links).unwrap()
}
pub fn add_link(req: String, db: &Connection) -> (bool, String) {
let mut chunks: Url = from_str(&req).unwrap();
let mut chunks: Url = serde_json::from_str(&req).unwrap();
let style = env::var("slug_style").unwrap_or(String::from("Pair"));
let len_str = env::var("slug_length").unwrap_or(String::from("8"));