# README
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
-
Clone the repository:
git clone https://github.com/harsh082ip/URL-Shortener_Go.git cd URL-Shortener_Go
-
Install dependencies: Ensure you have Go installed on your machine. Then, run:
go mod tidy
-
Set up MongoDB and Redis:
- Install and start MongoDB.
- Install and start Redis.
-
Environment variables: Create a
.env
file and add your MongoDB and Redis configurations. -
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.
- Request body:
-
POST /auth/login
- Request body:
{ "email": "your email", "password": "your password" }
- Response: Status, session information, and session ID.
- Request body:
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.
- Request body:
-
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.
- Request body:
-
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
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes.
- Push to the branch.
- 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.
# Packages
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author
No description provided by the author