url-shortener

module
v0.0.0-...-10a49dc Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Jan 6, 2024 License: MIT

README

URL Shortener

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

  1. Clone the repository:

    git clone https://github.com/bayonetto666/url-shortener.git
    cd url-shortener
    
  2. Install dependencies:

    go mod tidy
    
  3. Configure the application:

    Create a config.json file based on the provided template and adjust the settings accordingly.

  4. Run the application:

    go run ./cmd/app.go
    
  5. 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"

Then you can try it

curl -X GET "http://localhost/{cache_code}

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL