The URL Shortener is a simple service that allows users to create shortened URLs for long, cumbersome links. It uses a combination of MongoDB and Redis for data storage and caching.
Features
Shorten long URLs into concise, easy-to-share links.
MongoDB database for persistent storage of original and shortened URLs.
Redis caching to enhance performance and reduce database load.
Configuration file (config.json) for easy customization of server and database settings.
Prerequisites
Make sure you have the following installed:
Go
MongoDB
Redis
Getting Started
Clone the repository:
git clone https://github.com/bayonetto666/url-shortener.git
cd url-shortener
Install dependencies:
go mod tidy
Configure the application:
Create a config.json file based on the provided template and adjust the settings accordingly.
Run the application:
go run ./cmd/app.go
Access the service:
Open your web browser and navigate to http://localhost:8080.
Configuration
server : Configuration related to the HTTP server.
database: Configuration for MongoDB.
cache : Configuration for Redis (used as a cache).
domain : Configuration for a domain.
Usage
Shorten URL
Send a POST request to /shorten with the url parameter:
curl -X POST "http://localhost:8080/shorten?url=https://www.example.com"