This project implements a microservice for shortening URLs. Users can input a long URL and receive a shortened URL in return. The service also handles redirection from the shortened URL back to the original long URL.
Clone the repository: https://github.com/chatgut/URLShortenerService2024.git docker-compose up --buildThis will start two services:
- url_shortener: Runs the URL shortener service on port 8080.
- db: A MySQL database used by the URL shortener.
POST http://localhost:8080/shorten
Content-Type: application/json
{
"longUrl": "https://www.google.com"
}
- Response should look like this:
{
"longUrl": "https://www.google.com",
"shortUrl": "abc123",
"message": "URL successfully shortened"
}
- Use GET request to access the shortened URL to get redirected:
http://localhost:8080/{shortUrl}
For example, if your short URL is abc123, visiting http://localhost:8080/abc123 will redirect you to the original https://www.google.com.