Skip to content

πŸ”— Efficient URL shortener service, designed for quick and reliable link management πŸš€, ensuring seamless redirection and easy scalability.

License

Notifications You must be signed in to change notification settings

harsh082ip/URL-Shortener_Go

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

22 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

URL Shortener in Go using Gin

Welcome to the URL Shortener service built with Go and the Gin web framework! This project allows users to shorten URLs and retrieve the original URLs using a short identifier.

Table of Contents

Installation

  1. Clone the repository:

    git clone https://github.com/harsh082ip/URL-Shortener_Go.git
    cd URL-Shortener_Go
  2. Install dependencies: Ensure you have Go installed on your machine. Then, run:

    go mod tidy
  3. Set up MongoDB and Redis:

    • Install and start MongoDB.
    • Install and start Redis.
  4. Environment variables: Create a .env file and add your MongoDB and Redis configurations.

  5. Run the application:

    go run main.go

Usage

  • Signup: Create a new user account.
  • Login: Authenticate an existing user.
  • Shorten URL: Generate a shortened URL.
  • Redirect: Use the shortened URL to redirect to the original URL.

Features

  • User authentication (signup and login)
  • URL shortening
  • URL redirection
  • Visit tracking and caching with Redis

API Endpoints

Auth Routes

  • POST /auth/signup

    • Request body:
      {
          "name": "your name",
          "email": "your email",
          "password": "your password"
      }
    • Response: Status and message indicating the result of the signup.
  • POST /auth/login

    • Request body:
      {
          "email": "your email",
          "password": "your password"
      }
    • Response: Status, session information, and session ID.

URL Routes

  • POST /url/shorten?sessionID=YOUR_SESSION_ID

    • Request body:
      {
          "redirecturl": "URL to be shortened",
          "createdby": "user's email"
      }
    • Response: The shortened URL information.
  • POST /url/customshorten?sessionID=YOUR_SESSION_ID

    • Request body:
      {
          "shortid": "custom short ID",
          "redirecturl": "URL to be shortened",
          "createdby": "user's email"
      }
    • Response: The shortened URL information.
  • GET /:shortid

    • Redirects to the original URL corresponding to the given short ID.

Technologies Used

  • Gin: A web framework for Go. Used for building the HTTP server and defining routes.
  • MongoDB: A NoSQL database used for storing user information, URLs, and session data.
  • Redis: An in-memory data store used for caching and session management.

Contributing

  1. Fork the repository.
  2. Create a new branch for your feature or bug fix.
  3. Commit your changes.
  4. Push to the branch.
  5. Create a Pull Request.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Contact

For questions or feedback, please contact me.

About

πŸ”— Efficient URL shortener service, designed for quick and reliable link management πŸš€, ensuring seamless redirection and easy scalability.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published