Skip to content

mukhtarpatel11/code-test-instructions

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

12 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Simple URL Shortener

Run application locally

  • Install docker
  • clone repository
  • Launch a terminal, from the root of the project run docker-compose up --build

To create a new short url using UI

  • On a browser navigate to http://localhost:8080/
  • Enter a fully qualified url, alias is optional
  • Select Shorten to generate a short url
  • The new url will be displayed at the bottom as shown below, click on it to navigate.

img_1.png

Using API

There are several options when it comes to invoking REST API, for this example we use curl

  • To list existing shortened endpoints

    curl --location --request GET 'localhost:8080/urls'

  • To shorten url with alias

    curl --location --request POST 'localhost:8080/shorten'
    --header 'Content-Type: application/json'
    --data-raw '{ "fullUrl" : "http://www.itv.co.uk", "customAlias" : "i" }'

  • To shorten url without alias

    curl --location --request POST 'localhost:8080/shorten'
    --header 'Content-Type: application/json'
    --data-raw '{ "fullUrl" : "http://www.itv.co.uk" }'

  • To redirect to a shortened url supply the alias as a path parameter via GET call. Alias can be obtained by invoking the urls endpoint

    curl --location --request GET 'localhost:8080/47SDa'

  • To delete a existing shortened url supply the alias as a path parameter via DELETE call. Alias can be obtained by invoking the urls endpoint

    curl --location --request DELETE 'localhost:8080/47SDa'

Assumptions

  • Basic client side URL validation is performed.
  • For redirects a 302 response code is used, which as per Open API spec will handle redirects.
  • Does not implement race condition handling
  • Does not implement security, it is assumed the application will only run locally.
  • For the sake of this example an embedded H2 database is used

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Contributors 2

  •  
  •