Skip to content

maczam/bitly-clone

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bitly-Clone

Introduction

As a Java web-app, this is a simplied clone to the famous Bitly (https://bitly.com) service. The main function is:

Given an input url, create a 'shortened' url that will redirect a user to the original content.

Purpose

To demostracte my java programming level and software engineering abaility, since this is originally a task from a technical test.

The following de-faco standard technologies were used for demostration purpose:

  • [Spring Framework] - for dependency injection and restful controller
  • [Hibernate] - for ORM
  • [Log4j2] - for logging
  • [JUnit] - for unit testing
  • [JMock] - for mocking at unit testing

Installation

  1. deploy the bitly-clone.war to the servlet container
  2. create the config file: file:${catalina.home}/conf/bitly.properties

properties:

example:

bitly.domainUrl=https://bitly-clone
bitly.hashMethod=MD5

Restful API

list all shortened urls

method: GET
path: /list
requestbody: none
responsebody: json list to show all shortened urls

example response:

[
{
  "originalUrl" : "http://apple.com/123/123",
  "shortenUrl": "https://bitly-clone.com/4999af664c462fb0c4edfc2171da1f9b"
  "date":1460919344891
},
{
  "originalUrl" : "http://test.test.test.test.test.com",
  "shortenUrl": "https://bitly-clone.com/4999af67812k2fb0c4e12ee671da1fff"
  "date":1460919345892
}
]

create a shortened url

method: POST
path: /
requestbody: raw string of the original url to be inputed
responsebody: json object contains the shortened url along with the original url

example response:

{
  "originalUrl" : "http://apple.com/123/123",
  "shortenUrl": "https://bitly-clone.com/4999af664c462fb0c4edfc2171da1f9b"
}

redirect url

method: GET
path: /{shortened url}
responseheader: http 301 status would response with location equals the original url 

Known Issues

As a demostraction, the following issues are not going to be solved, but I know thier existence.

  • The hash of the shortened url may be collided
  • It is supposed to shortened only GET request
  • http-to-https or https-to-http problem

About

Java Restful Webservice: Given an input url, create a 'shortened' url that will redirect a user to the original content.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Java 74.1%
  • CSS 19.3%
  • JavaScript 3.6%
  • HTML 3.0%