Skip to content

IEEE-RVCE/url-shortner

Repository files navigation

IEEE RVCE URL Shortner

Made using Golang and Redis (Key Value Store) to enable fast access to db records and low latency redirection.

How to run

make sure you have go installed and docker installed

  • Bring Up Redis Instance
docker-compose up -d
  • Download all the dependencies
go mod download
  • Build the artifact
go build .
  • Run the server
./url-shortner

How this works

How this works

Decoding

When the user makes a request to decode endpoint, handler forwards the request to store and the store checks if the short url is already present in the redis, if it is present then it redirects to the long url

API DOC

There are 3 endpoints,

Development Host is http://localhost:8080

Production Host is hided to avoid spam

  • POST /api/encode

Payload

{
  "long_url": "https://ieee-rvce.org",
  "user_id": "UwQPr3aIf9dM5x7r",
  "custom_text": "main_website"
}

Response

{
  "short_url": "http://localhost:8080/main_website"
}

You might ask why user_id is required, it is required to construct the short url. When the custom_text is not provided, the short url is constructed using the user_id and the custom_text and the short url is unique for each user and custom_text combination.

  • GET /api/decode/:short_url

Response

{
  "long_url": "https://ieee-rvce.org",
  "short_url": "http://localhost:8080/main_website"
}
  • GET /api/:short_url

Redirects to the long url, passing 301 status code.

TBD

  • Dockerise the whole thing;
  • [] Check If the short_url is valid iff redirect; if not then display a page with proper error message
  • [] Right Now we are storing the data for 6 hours, should see into making it store permanently
  • [] Should add a way to delete the data
  • [] Should add a way to update the data
  • [] Analytics? (Is it possible to track no of clicks, location , etc...)
  • [] Maybe a UI to add Data

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published