Skip to content

harmoniousmoss/Rust-URL-Shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

10 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

πŸš€ Rust URL Shortener

A simple URL Shortener built with Rust and Actix Web, using in-memory storage (HashMap).

🌟 Features

βœ… Shorten a long URL with a user-defined short code
βœ… Retrieve the original URL using a short code
βœ… Redirect users to the original URL
βœ… Prevent duplicate short URLs
βœ… In-memory storage (no database required)
βœ… Simple and lightweight API


πŸ”— API Usage

1️⃣ Shorten a URL (User-Defined Short Code)

Endpoint:

POST /shorten

Request Body (JSON format):

{
    "long_url": "https://www.rust-lang.org",
    "short_url": "rusturlshortener"
}

Example Request (Using Curl):

curl -X POST -H "Content-Type: application/json" \
     -d '{"long_url": "https://www.rust-lang.org", "short_url": "rusturlshortener"}' \
     http://127.0.0.1:8080/shorten

Example Response:

"Shortened URL: http://127.0.0.1:8080/rusturlshortener"

2️⃣ Redirect to the Original URL

GET /{short_code}

πŸ›  Technologies Used

  • Rust πŸ¦€
  • Actix Web (for building web APIs)
  • Lazy_static (for global HashMap storage)
  • Tokio (for async execution)

About

A simple URL Shortener built with Rust and Actix Web, using in-memory storage (HashMap).

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages