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

Compare commits

...

2 commits

5 changed files with 18 additions and 16 deletions

View file

@ -133,9 +133,11 @@ 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
links. Listing existing links or deleting links will need admin access using the password.
By default, the server sends `no-cache` and `private` Cache-Control headers. To disable those,
set `cache_control_header` to `Disable`. It might help boost performance if served through a
proxy.
By default, the server sends no Cache-Control headers. You can set custom `cache_control_header`
to send your desired headers. It must be a comma separated list of valid
[RFC 7234 §5.2](https://datatracker.ietf.org/doc/html/rfc7234#section-5.2) headers. For example,
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
The application can be used from the terminal using something like `curl`. In all the examples
@ -179,6 +181,6 @@ pointing to illegal content. Since there are no logs, it's impossible to prove
that those links aren't created by you.
## Notes
- It started as a fork of [this project](https://gitlab.com/draganczukp/simply-shorten).
- It started as a fork of [`simply-shorten`](https://gitlab.com/draganczukp/simply-shorten).
- 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).

6
actix/Cargo.lock generated
View file

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

View file

@ -3,7 +3,7 @@
[package]
name = "chhoto-url"
version = "5.3.1"
version = "5.4.0"
edition = "2021"
authors = ["Sayantan Santra <sayantan[dot]santra689[at]gmail[dot]com"]
license = "mit"

View file

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

View file

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