Skip to content

chatgut/URLshortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener Microservice

This microservice provides functionality to generate shortened URLs and resolve them back to their original URLs. It is built using Spring Boot and uses MongoDB as its database.

How to Run

  1. Clone the repository

git clone https://github.com/chatgut/URLshortener.git

  1. Navigate to the project

cd URLshortener

  1. Build and run the services:

    docker-compose up --build

    This will start two services: url_shortener: The URL shortener service available on port 8080. mongo: The MongoDB database for storing URL mappings.

Testing the Service

  1. Shorten a URL

Send a POST request to shorten a long URL:

Endpoint: POST http://localhost:8080/api/v1/urls/shorten

Request Body:

{
"originalUrl": "https://www.example.com"
}

Response Example:

{
"shortenedUrl": "abcd1234"
}

  1. Resolve a Shortened URL

Use a GET request to retrieve the original URL:

Endpoint: GET http://localhost:8080/api/v1/urls/{shortenedUrl}

Replace {shortenedUrl} with the value returned from the POST request.

Example: GET http://localhost:8080/api/v1/urls/abcd1234

Response Example: The original URL (e.g., https://www.example.com) will be returned as plain text. Notes

Ensure Docker is installed and running on your system before starting the services.
MongoDB data is stored in a container volume, so it persists between container restarts.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors