1
0
Fork 0
mirror of https://github.com/SinTan1729/chhoto-url synced 2024-12-28 08:28:36 -06:00

Compare commits

..

No commits in common. "114a97a2731878afe0f00c5522d87a4b7e0d7874" and "69fc25a26471517dac6c372c309f34a31e042496" have entirely different histories.

5 changed files with 16 additions and 18 deletions

View file

@ -133,11 +133,9 @@ the `slug_length` variable. It defaults to 8, and a minimum of 4 is supported.
To enable public mode, set `public_mode` to `Enable`. With this, anyone will be able to add To enable public mode, set `public_mode` to `Enable`. With this, anyone will be able to add
links. Listing existing links or deleting links will need admin access using the password. links. Listing existing links or deleting links will need admin access using the password.
By default, the server sends no Cache-Control headers. You can set custom `cache_control_header` By default, the server sends `no-cache` and `private` Cache-Control headers. To disable those,
to send your desired headers. It must be a comma separated list of valid set `cache_control_header` to `Disable`. It might help boost performance if served through a
[RFC 7234 §5.2](https://datatracker.ietf.org/doc/html/rfc7234#section-5.2) headers. For example, proxy.
you can set it to `no-cache, private` to disable caching. It might help during testing if
served through a proxy.
## Instructions for CLI usage ## Instructions for CLI usage
The application can be used from the terminal using something like `curl`. In all the examples The application can be used from the terminal using something like `curl`. In all the examples
@ -181,6 +179,6 @@ pointing to illegal content. Since there are no logs, it's impossible to prove
that those links aren't created by you. that those links aren't created by you.
## Notes ## Notes
- It started as a fork of [`simply-shorten`](https://gitlab.com/draganczukp/simply-shorten). - It started as a fork of [this project](https://gitlab.com/draganczukp/simply-shorten).
- The list of adjectives and names used for random short url generation is a modified - The list of adjectives and names used for random short url generation is a modified
version of [this list used by docker](https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go). version of [this list used by docker](https://github.com/moby/moby/blob/master/pkg/namesgenerator/names-generator.go).

6
actix/Cargo.lock generated
View file

@ -468,7 +468,7 @@ checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd"
[[package]] [[package]]
name = "chhoto-url" name = "chhoto-url"
version = "5.4.0" version = "5.3.1"
dependencies = [ dependencies = [
"actix-files", "actix-files",
"actix-session", "actix-session",
@ -1401,9 +1401,9 @@ checksum = "1f3ccbac311fea05f86f61904b462b55fb3df8837a366dfc601a0161d0532f20"
[[package]] [[package]]
name = "tokio" name = "tokio"
version = "1.38.0" version = "1.37.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "ba4f4a02a7a80d6f274636f0aa95c7e383b912d41fe721a31f29e29698585a4a" checksum = "1adbebffeca75fcfd058afa480fb6c0b81e165a0323f9c9d39c9697e37c46787"
dependencies = [ dependencies = [
"backtrace", "backtrace",
"bytes", "bytes",

View file

@ -3,7 +3,7 @@
[package] [package]
name = "chhoto-url" name = "chhoto-url"
version = "5.4.0" version = "5.3.1"
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

@ -36,7 +36,8 @@ async fn main() -> Result<()> {
let cache_control_header = env::var("cache_control_header") let cache_control_header = env::var("cache_control_header")
.ok() .ok()
.filter(|s| !s.trim().is_empty()); .filter(|s| !s.trim().is_empty())
.unwrap_or(String::from("Enable"));
// Actually start the server // Actually start the server
HttpServer::new(move || { HttpServer::new(move || {
@ -53,10 +54,10 @@ async fn main() -> Result<()> {
.app_data(web::Data::new(AppState { .app_data(web::Data::new(AppState {
db: database::open_db(db_location.clone()), db: database::open_db(db_location.clone()),
})) }))
.wrap(if let Some(header) = &cache_control_header { .wrap(if cache_control_header == "Disable" {
middleware::DefaultHeaders::new().add(("Cache-Control", header.to_owned()))
} else {
middleware::DefaultHeaders::new() middleware::DefaultHeaders::new()
} else {
middleware::DefaultHeaders::new().add(("Cache-Control", "no-cache, private"))
}) })
.service(services::link_handler) .service(services::link_handler)
.service(services::getall) .service(services::getall)

View file

@ -36,10 +36,9 @@ services:
# delete, or listing), change the following option to Enable. # delete, or listing), change the following option to Enable.
# - public_mode=Disable # - public_mode=Disable
# By default, the server sends no Cache-Control headers. You can supply a # By default, the server sends `no-cache` and `private` Cache-Control
# comma separated list of valid header as per RFC 7234 §5.2 to send those # headers. To disable those, change the following option to Disable.
# headers instead. # - cache_control_header=Enable
# - cache_control_header=no-cache, private
volumes: volumes:
- db:/urls.sqlite - db:/urls.sqlite
networks: networks: