1
0
Fork 0
mirror of https://github.com/SinTan1729/chhoto-url synced 2025-04-20 11:50:01 -05:00

Compare commits

..

No commits in common. "f6060eb649c0d7aeb7908b97a8a70bf91911029c" and "f9e642275a4ab608e5b58aa184e64cf90d02467a" have entirely different histories.

5 changed files with 15 additions and 25 deletions

View file

@ -116,11 +116,8 @@ docker run -p 4567:4567 \
-d chhoto-url:latest -d chhoto-url:latest
``` ```
You can set the redirect method to Permanent 308 (default) or Temporary 307 by setting You can also set the redirect method to Permanent 308 (default) or Temporary 307 by setting
the `redirect_method` variable to `TEMPORARY` or `PERMANENT` (it's matched exactly). By the `redirect_method` variable to `TEMPORARY` or `PERMANENT` (it's matched exactly).
default, the auto-generated links are adjective-name pairs. You can use UIDs by setting
the `slug_style` variable to `UID`. You can also set the length of those slug by setting
the `slug_length` variable. It defaults to 8, and a minimum of 4 is supported.
## Disable authentication ## Disable authentication
If you do not define a password environment variable when starting the docker image, authentication If you do not define a password environment variable when starting the docker image, authentication

18
actix/Cargo.lock generated
View file

@ -88,7 +88,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb" checksum = "e01ed3140b2f8d422c68afa1ed2e85d996ea619c988ac834d255db32138655cb"
dependencies = [ dependencies = [
"quote", "quote",
"syn 2.0.57", "syn 2.0.55",
] ]
[[package]] [[package]]
@ -217,7 +217,7 @@ dependencies = [
"actix-router", "actix-router",
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.57", "syn 2.0.55",
] ]
[[package]] [[package]]
@ -475,7 +475,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "chhoto-url" name = "chhoto-url"
version = "5.2.0" version = "5.1.0"
dependencies = [ dependencies = [
"actix-files", "actix-files",
"actix-session", "actix-session",
@ -1047,9 +1047,9 @@ checksum = "e3148f5046208a5d56bcfc03053e3ca6334e51da8dfb19b6cdc8b306fae3283e"
[[package]] [[package]]
name = "pin-project-lite" name = "pin-project-lite"
version = "0.2.14" version = "0.2.13"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" checksum = "8afb450f006bf6385ca15ef45d71d2288452bc3683ce2e2cacc0d18e4be60b58"
[[package]] [[package]]
name = "pin-utils" name = "pin-utils"
@ -1237,7 +1237,7 @@ checksum = "7eb0b34b42edc17f6b7cac84a52a1c5f0e1bb2227e997ca9011ea3dd34e8610b"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.57", "syn 2.0.55",
] ]
[[package]] [[package]]
@ -1338,9 +1338,9 @@ dependencies = [
[[package]] [[package]]
name = "syn" name = "syn"
version = "2.0.57" version = "2.0.55"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "11a6ae1e52eb25aab8f3fb9fca13be982a373b8f1157ca14b897a825ba4a2d35" checksum = "002a1b3dbf967edfafc32655d0f377ab0bb7b994aa1d32c8cc7e9b8bf3ebb8f0"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
@ -1680,7 +1680,7 @@ checksum = "9ce1b18ccd8e73a9321186f97e46f9f04b778851177567b1975109d26a08d2a6"
dependencies = [ dependencies = [
"proc-macro2", "proc-macro2",
"quote", "quote",
"syn 2.0.57", "syn 2.0.55",
] ]
[[package]] [[package]]

View file

@ -1,6 +1,6 @@
[package] [package]
name = "chhoto-url" name = "chhoto-url"
version = "5.2.0" version = "5.1.0"
edition = "2021" edition = "2021"
authors = ["Sayantan Santra <sayantan[dot]santra689[at]gmail[dot]com"] authors = ["Sayantan Santra <sayantan[dot]santra689[at]gmail[dot]com"]
license = "mit" license = "mit"

View file

@ -28,8 +28,8 @@ pub fn add_link(req: String, db: &Connection) -> (bool, String) {
let chunks: Vec<&str> = req.split(';').collect(); let chunks: Vec<&str> = req.split(';').collect();
let longlink = String::from(chunks[0]); let longlink = String::from(chunks[0]);
let style = env::var("slug_style").unwrap_or(String::from("Pair")); let style = env::var("slug-style").unwrap_or(String::from("pair"));
let len_str = env::var("slug_length").unwrap_or(String::from("8")); let len_str = env::var("slug-length").unwrap_or(String::from("8"));
let mut len: usize = len_str.parse().unwrap_or(8); let mut len: usize = len_str.parse().unwrap_or(8);
if len < 4 { if len < 4 {
len = 4; len = 4;
@ -99,7 +99,7 @@ fn gen_link(style: String, len: usize) -> String {
static CHARS: [char; 36] = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', static CHARS: [char; 36] = ['a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x',
'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9']; 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9'];
if style == "UID" { if style == "uid" {
nanoid!(len, &CHARS) nanoid!(len, &CHARS)
} else { } else {
format!( format!(

View file

@ -21,13 +21,6 @@ services:
# Pass the redirect method, if needed TEMPORARY and PERMANENT # Pass the redirect method, if needed TEMPORARY and PERMANENT
# are accepted values, defaults to PERMANENT # are accepted values, defaults to PERMANENT
# - redirect_method=TEMPORARY # - redirect_method=TEMPORARY
# By default, the auto-generated pairs are adjective-name pairs
# If you want UIDs, please change slug_style to UID
# Supported values for slug_style are "Pair" and "UID"
# The length is 8 by default, and a minimum of 4 is allowed
# - slug_style=Pair
# - slug_length=8
volumes: volumes:
- db:/urls.sqlite - db:/urls.sqlite
networks: networks: