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.
-
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
- 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.
- User authentication (signup and login)
- URL shortening
- URL redirection
- Visit tracking and caching with Redis
-
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:
-
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.
- 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.
- Fork the repository.
- Create a new branch for your feature or bug fix.
- Commit your changes.
- Push to the branch.
- Create a Pull Request.
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or feedback, please contact me.