Plain implementation of the URL shortening service.
- Configurable HTTP redirect status code, either 301 or 302
- Keeping count of redirections for each URL
- Fetching URLs shortened by a certain account
- HTTP Basic authentication
- Access through the secured REST API
To start a web application, clone the project and run it:
git clone git@github.com:riguron/URLShortener.git
cd URLShortener
mvn clean spring-boot:run
In order to shorten URLs, you need to open an account:
curl --header "Content-Type: application/json" \
--request POST \
--data '{"AccountId":"JohnDoe"}' \
http://localhost:8080/api/account
The response looks like:
{
"success":true,
"description":"Your account is opened",
"password":"UY5uD96d"
}
Now you are able to shorten URLs:
curl --header "Content-Type: application/json" \
--user JohnDoe:UY5uD96d \
--request POST \
--data '{"url":"https://www.google.com/"}' \
http://localhost:8080/api/register
Shortening will be returned in the following format:
{
"url":"AGiKGd"
}
Now, http://localhost:8080/AGiKGd will redirect you to https://www.google.com/
You may also view redirection stats for your account:
curl --header "Content-Type: application/json" \
--user JohnDoe:UY5uD96d \
--request GET \
http://localhost:8080/api/stats
Account statistics will be returned in the following format:
{
"https://www.apple.com/":5,
"https://www.google.com/":7
}
- Spring Boot
- Spring Security
- Spring Data
- Hibernate 5
- HSQL Database
- Lombok
- Maven