An API to short URLs. You can send a long URL and get a short link to it.
It was implemented using SpringBoot and uses, by default, Tomcat.
The API has two endpoints:
Create the short URL:
curl -X POST http://localhost:8080/shorten -H 'Content-type:application/json' -d '{"url": "http://www.google.com"}'
The response:
{
"originalUrl": "http://www.google.com",
"shortUrl": "http://localhost:8080/L"
}
Redirect to the original URL used to create this link
curl -i http://localhost:8080/L
Will redirect to the original URL:
HTTP/1.1 301
Location: http://www.google.com
Content-Length: 0
Date: Mon, 18 Mar 2019 15:56:55 GMT
If the short url informed does not exist it will return a 404 Not Found.
The domain can be set in resources/application.properties
:
# Domain property
shortUrl.domain=http://localhost:8080
mvn clean install
mvn spring-boot:run
The server will be started on port 8080
.
This project uses docker-maven-plugin
by Spotify.
To generate the image:
mvn clean package docker:build