Skip to content

Yash-sudo-web/urlShortnerRedisGolang

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

URL Shortener with Redis and GoFiber

This project provides a RESTful API for shortening URLs using Redis for storage and GoFiber as the web framework. Docker and Docker-compose is used for containerization and deployment, ensuring consistent behavior across different environments.

Features

  • Shorten long URLs into shorter, more manageable links.
  • Resolve shortened URLs to their original long form.
  • Rate limiting to prevent abuse and ensure fair usage.
  • Docker used for containerization and deployment.

Prerequisites

Make sure you have Go and Redis installed on your machine if you want to run it without docker. You can download and install go from here and redis from here.

Dependencies

  • GoFiber: A fast and lightweight web framework for Go.
  • Redis: An open-source, in-memory data structure store used as a database, cache, and message broker.
  • go-redis/redis: Go client for Redis.
  • joho/godotenv: A Go library for loading environment variables from a .env file.
  • asaskevich/govalidator: A package of validators and sanitizers for strings, structs, and collections.
  • google/uuid: A Go package for UUIDs (Universally Unique Identifiers) generation and parsing.

Installation

  1. Clone the repository:

    https://github.com/Yash-sudo-web/urlShortnerRedisGolang.git
    
  2. Navigate to the project directory:

    cd urlshortnerredisgolang
    
  3. Add ".env" file to configure enviromental variables, Example .env file:

    REDIS_URL="db:6379"
    REDIS_PASSWORD=""
    APP_PORT=":3000"
    DOMAIN="http://localhost:3000"
    API_QUOTA=10
    
  4. Build and run the application using Docker Compose:

    docker-compose up --build
    

API Endpoints

  • POST /shorten: Shorten a long URL.
  • GET /{url}: Resolve a shortened URL.

Usage

You can use tools like cURL or Postman to interact with the API endpoints. Here are some examples:

  • Send a POST request to /shorten with a JSON payload containing the URL to be shortened:

    curl -X POST -H "Content-Type: application/json" -d '{"url": "https://example.com"}' http://localhost:3000/shorten
    
  • To resolve a shortened URL, simply append the shortened code to the base URL:

    curl http://localhost:3000/{shortened_code}
    

Contributing

Contributions are welcome! Feel free to open issues or submit pull requests.

License

This project is licensed under the MIT License.

About

No description, website, or topics provided.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors