1 unstable release

0.1.0 Oct 7, 2023

#28 in #link-shortener

MIT license

36KB
240 lines

bref

A modest URL shortener for personal usage.

Shortens URLs to a 6 characters-length key that is generated based on current time. Why? Why not?

Usage

Shorten a URL

$ http post :8080 url="https://ngryman.sh"
HTTP/1.1 200 OK
content-length: 40
content-type: application/json
date: Sat, 07 Oct 2023 13:16:43 GMT

{
    "key": "1qp7Ah",
    "url": "https://ngryman.sh"
}

Redirect

$ http get :8080/1qp6Oj
HTTP/1.1 307 Temporary Redirect
content-length: 0
date: Sat, 07 Oct 2023 13:17:43 GMT
location: https://ngryman.sh

Deployment

Bref can easily be deployed to fly.io. Please refer to the deploy workflow pipeline.


lib.rs:

Bref is a simple URL shortener that generates a unique key for each URL and stores it in a local database.

It is designed to be used as as standalone server, but can be used as a library.

Usage

use bref::Bref;

#[tokio::main]
async fn main() -> Result<()> {
  Bref::default().run().await
}

Dependencies

~14–23MB
~297K SLoC