Skip to content

Basic implementation of the URL shortening service

License

Notifications You must be signed in to change notification settings

jolice/URLShortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

30 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URLShortener

Build Status codecov

Plain implementation of the URL shortening service.

Features

  • 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

Running

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

Usage

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
}

Technologies used

  • Spring Boot
  • Spring Security
  • Spring Data
  • Hibernate 5
  • HSQL Database
  • Lombok
  • Maven