This is a minimalistic web service that shortens an URL. This service saves the original and shortened URLs in a Redis database for quick retrieval. The project leverages a minimal API style using .NET to ensure a clean and efficient codebase.
- Docker installed on your machine.
-
Clone the Repository
git clone <repository-url> cd url-shortener
-
Build and Run the Docker Containers
Use Docker Compose to build and start both the URL Shortener API and Redis containers.
docker-compose up --build
-
Access the API
Once the containers are up and running, the URL Shortener API will be accessible at:
http://localhost:3001
-
Shorten URL
POST /shorten
Request Body:
{ "url": "https://example.com" }
Response:
{ "message": "success", "shortUrl": "http://localhost:5000/abc123" }
-
Redirect to Original URL
GET /{shortUrl}
Accessing the shortened URL will redirect to the original URL.
To stop the running containers, use:
docker-compose down