mirror of
https://github.com/minoplhy/chhoto-url.git
synced 2024-11-22 09:16:46 +00:00
chg: Changed some struct names
This commit is contained in:
parent
4f80b1b522
commit
34518affaf
@ -2,7 +2,7 @@ use rusqlite::Connection;
|
||||
use serde::Serialize;
|
||||
|
||||
#[derive(Serialize)]
|
||||
pub struct DbRow {
|
||||
pub struct DBRow {
|
||||
shortlink: String,
|
||||
longlink: String,
|
||||
hits: i64,
|
||||
@ -18,14 +18,14 @@ pub fn find_url(shortlink: &str, db: &Connection) -> Option<String> {
|
||||
.ok()
|
||||
}
|
||||
|
||||
pub fn getall(db: &Connection) -> Vec<DbRow> {
|
||||
pub fn getall(db: &Connection) -> Vec<DBRow> {
|
||||
let mut statement = db.prepare_cached("SELECT * FROM urls").unwrap();
|
||||
|
||||
let mut data = statement.query([]).unwrap();
|
||||
|
||||
let mut links: Vec<DbRow> = Vec::new();
|
||||
let mut links: Vec<DBRow> = Vec::new();
|
||||
while let Some(row) = data.next().unwrap() {
|
||||
let row_struct = DbRow {
|
||||
let row_struct = DBRow {
|
||||
shortlink: row.get("short_url").unwrap(),
|
||||
longlink: row.get("long_url").unwrap(),
|
||||
hits: row.get("hits").unwrap(),
|
||||
|
@ -8,7 +8,7 @@ use rusqlite::Connection;
|
||||
use serde::Deserialize;
|
||||
|
||||
#[derive(Deserialize)]
|
||||
struct Url {
|
||||
struct URLPair {
|
||||
shortlink: String,
|
||||
longlink: String,
|
||||
}
|
||||
@ -32,7 +32,7 @@ pub fn getall(db: &Connection) -> String {
|
||||
}
|
||||
|
||||
pub fn add_link(req: String, db: &Connection) -> (bool, String) {
|
||||
let mut chunks: Url = serde_json::from_str(&req).unwrap();
|
||||
let mut chunks: URLPair = 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"));
|
||||
|
Loading…
Reference in New Issue
Block a user