Giter Site home page Giter Site logo

maczam / bitly-clone Goto Github PK

View Code? Open in Web Editor NEW

This project forked from davidwonghk/bitly-clone

0.0 2.0 0.0 56 KB

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

Java 74.14% CSS 19.25% HTML 3.03% JavaScript 3.57%

bitly-clone's Introduction

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

bitly-clone's People

Contributors

davidwonghk avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.