URL-Redis

Implementing URL shortening with Go and Redis as cache with Rate Limiting.

In this project I have tried to implement on of daily task used in any marketing or sales domain organisation which is URL Shortning using Go, Redis, Docker, Docker-compose. The backend is designed and developed in Golang while Redis is used as cache DB. I wanted to implement Rate limiting so i have also applied rate limiting to restrict the user for it and over burdening the server. I have wraped the application in Docker and using Docker compose the make a dev/prod ready containerised application.

The API Specs are below for raising the POST request
URL       string       json:"url"
CustomShort   string       json:"short"
Expiry      time.Duration   json:"expiry"

The response we will be getting in the below format(JSON)
URL         string      json:"url"
CustomShort      string      json:"short"
Expiry         time.Duration   json:"expiry"
XRateRemaining   int         json:"rate_limit"
XRateLimitReset    time.Duration   json:"rate_limit_reset"

For rate limiting, this logic applies to allow only 10 request per 30 min we can change it as per our requirement and the response shows how much time is left in resetting the request limiter.

GitHub

View Github