URL shortener service
After cloning repository executable jar file with all dependencies is available in target/ directory. If you wish to compile and run simply use Maven:
mvn spring-boot:run
Application exposes three REST endpoints: account, register and statistic.
Endpoint used for registration of new users. Required headers:
- Content-Type: application/json Content body must contain "AccountId" with desired username.
{ "AccountId": "shortly" }
If account generation was successful response containing password is sent.
{
"success": true,
"description": "Successfully added account",
"password": "KOgcbJiM"
}
Endpoint for registering new URLs. Required headers:
- Content-Type: application/json
- Authorization: Basic $credentials
Content body can contain:
- url - URL to be shortend
- redirectType - 301 or 302 HTTP status code (default: 302)
Response will contain short URL:
{
"success": true,
"shortUrl": "http://shortly.net/Rgm8Bs"
}
Endpoint for retrieving statistics by user. Required headers:
- Authorization: Basic $credentials
Response will contain all registered URLs and their hit count:
{
"https://github.com/srook": 17,
"https://google.com/someverylongquery": 3
}
Running test is simple with Maven:
mvn test
- Saša Rošić - https://github.com/srook
This project is licensed under the MIT License - see the LICENSE file for details