A simple URL Shortener built with Rust and Actix Web, using in-memory storage (HashMap
).
β
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
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"
GET /{short_code}
- Rust π¦
- Actix Web (for building web APIs)
- Lazy_static (for global HashMap storage)
- Tokio (for async execution)