Check out Rusly
Rusly is built using the Rocket framework
Check out the system design of Rusly here
Check out Rusly's simple HTML, CSS UI repo
Let's take a quick look at the available endpoints
Route | Description | Request Body | Response |
---|---|---|---|
/ GET |
The default home route | None | Hello Heckerr |
/v1/shorten POST |
Takes in the URL to shorten and returns the shortened URL. | - url_to_shorten : String url to shorten |
- shortened_url : A shortened string URL. |
- custom_link : Optional, strictly 7-character alphabetic custom shortened URL string |
- error : Error message string |
||
/<short-url GET |
Permanently redirects to the specified short URL string | None | None |
Currently, the SQLite database is used as an embedded database.
| VARCHAR(7) PRIMARY KEY |
| VARCHAR(1024) NOT NULL |
| INTEGER NOT NULL |
id
: The randomly generated string acts as the shortened URL string. This being a primary key ensures that there are no duplicate short URLs.
In the case of custom short URLs, it won't be allowed either.
Since the length of the short URL is 7 characters, there are over 8 billion possible combinations that are sufficient and uniqueness is maintained by the primary key.
fullUrl
: The full URL string. Is fetched and the user is redirected permanently.
timestamp
: The UNIX timestamp of entry. It is provided in the Rust code in the insert query. The commit time of the record and this timestamp may vary.
Rocket is multi-threaded by default, it spins up worker threads and divides the workload. More details here
Rocket provides database pools for providing database connection objects via state
It provides a rusqlite connection out of the box, with additional benefits of thread safety, and connection pooling.
-
Install Rust
You might need a specific version for Rocket, check the docs once. -
Clone this repo
-
Run
cargo run
It'll take some and Rusly will be up & running on127.0.0.1:8001
Following are the versions I used
rustc 1.68.2
cargo 1.68.2
Please refer to the CONTRIBUTING.md file and the open issues for any contribution and communication.