Skip to content

singhtaran1005/GO-shorty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

13 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Go - shorty

A Golang implementation of URL shortener just like : bitly

Tech stack 💻

goland-image go-fiber redis docker

Features included 📋

  • Rate limiting concept added along with expiry option to maintain service reliability.

  • Certain checks to ensure correct URL/domain creation.

  • Integrated Redis for scalable and persistent data storage.

  • Dockerized the whole application using Docker and Docker-compose

Project Setup 📎

  • Clone the repository using git clone <repoURL>

  • Go to the project working directory.

  • RUN go mod tidy to get all Golang dependencies

  • Install docker and docker-compose -> Install (Check docs for help during installation)

  • Create a .env file in the main working directory

    • Example .env file:
APP_PORT:(add your port)
DB_ADDR:(add your database port), used Redis mostly locally should be `:6379`
DB_PASS:(add your database password)
DOMAIN:(add your domain where the project will be hosted along with the port)
API_QUOTA:(set to 10 by default, you can choose some other number)
  • Run docker-compose up -d to spin docker containers for both Go-fiber and Redis.

  • Eventually, you can also set up a makefile to shorthand docker commands

  • YOUR Project is up NOW !!

  • To test it call API on Postman

  • POST request

    • (localhost:3000/api/v1)
{
    "url": "URL_TO_SHORT"
    "short": "CUSTOM_URL_ID"
}

where you will get a response :

{
    "url": "URL_TO_SHORT",
    "short": "SHORTEN_URL",
    "expiry": "SET IT TO A NUMBER say 30",
    "rate_limit": "{how many more number of times API can be called, which in our case will be 9}"
    "rate_limit_reset": "After how much time rate will reset"
}
  • GET request
    • (localhost:3000/:SHORTEN_URL) will redirect to the original URL.

About

url-shortner

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published