URL shortener to reduce a long link.
- Java
- Spring Boot
- Redis
- MongoDB
- Maven
mvn spring-boot:run
Request
curl --location --request POST 'localhost:8080/api/v1/user/' \
--header 'Content-Type: application/json' \
--data-raw '{
"name": "Pushpam Kumar"
}'
Response
{
"id": "6df4a87b-7aa7-4e62-9c7a-d9acfa400b9a",
"name": "Pushpam Kumar",
"apiKey": "54dae940a4c345859f5374e2e6c78638"
}
Creating short url
Request
curl --location --request POST 'localhost:8080/api/v1/link/create' \
--header 'Content-Type: application/json' \
--data-raw '{
"userId": "e6f09b6f-3486-4087-8d5d-b329725a3300",
"apiKey": "d8883a80f9c74195b9955c39358ea523",
"originalURL": "https://www.linkedin.com/in/pushpam-kumar/"
}'
Note: if apiKey is incorrect, it will throw 403 status code
Response
{
"http://localhost:8080/eUyZG"
}
Get original link from short link
Request
curl --location --request GET 'localhost:8080/api/v1/link/eUyZG'
Response
{
"https://www.linkedin.com/in/pushpam-kumar/"
}