Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/modprog/shorty
A small url shortener with minimal configuration
https://github.com/modprog/shorty
Last synced: 25 days ago
JSON representation
A small url shortener with minimal configuration
- Host: GitHub
- URL: https://github.com/modprog/shorty
- Owner: ModProg
- License: mit
- Created: 2021-08-17T09:16:29.000Z (over 3 years ago)
- Default Branch: main
- Last Pushed: 2021-09-25T23:22:22.000Z (over 3 years ago)
- Last Synced: 2024-10-28T12:36:14.885Z (2 months ago)
- Language: Rust
- Homepage:
- Size: 979 KB
- Stars: 0
- Watchers: 2
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.adoc
- License: LICENSE
Awesome Lists containing this project
README
= Shorty - URL shortener
:source-highlighter: rouge== Wordlists
The Corpora of the Universität Leipzig, licensed under https://creativecommons.org/licenses/by/4.0/[CC BY], are used for generating the wordlists. (https://web.archive.org/web/20210730003345/https://wortschatz.uni-leipzig.de/en/usage[Terms of Usage]) You can download the files here: https://wortschatz.uni-leipzig.de/en/download/English[Corpora].
== API
|===
| Method | Path | Description | Body | Response| POST
| `/w`
| Short a URL via wordlist
|
The URL to shorten
|
The shortened URL| POST
| `/c`
| Short a URL via random characters `[a-zA-Z0-9]`
|
The URL to shorten
|
The shortened URL| DELETE
a| `/`
| Deletes a shortened URL
Note that this is the same URL as the `GET`
|
|| GET
a| `/`
| Redirects to the matching `target` URL
|
a| `307`|===
== Configuration
You can configure `shorty` via environment variables. You can set those via the `--env` tag:
|===
| Name | Default | Description
| BASE_URL | `http://127.0.0.1:8000/` | The URL returned when shortening urls.
| CHARED_LENGTH | `4` | The length of the random characters used for shortened URL's.
| WORDED_LENGTH | `1` | The length of the random words used for shortened URL's.
| PASSWORD | *NOT-SET* | If set `POST` and `DELETE` requests are only authenticated with the cookie `PASSWORD` set to the correct password.
|===== Examples
You can run `shorty` with `docker` or `podman`:
```sh
podman run -p 8000:8000 ghcr.io/modprog/shorty
```
or
```sh
docker run -p 8000:8000 ghcr.io/modprog/shorty
```To set all configurable options:
```sh
podman run -p 8000:8000 \
--env WORDED_LENGTH=1 --env CHARED_LENGTH=4 --env BASE_URL=http://127.0.0.1:8000/ \
ghcr.io/modprog/shorty
```To shorten a URL make a `POST` request:
Using the wordlist:
```sh
curl -X POST http://localhost:8000/w -d https://togglebit.io/posts/terminal-game-jam/
```Using random characters:
```sh
curl -X POST http://localhost:8000/c -d https://togglebit.io/posts/terminal-game-jam/
```Afterwards just open the returned URL in a browser of your choice.