Skip to content

billybillysss/ShortifyGo

Folders and files

NameName
Last commit message
Last commit date

Latest commit

Β 

History

4 Commits
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 
Β 

Repository files navigation

Sure, here is an updated version of the README.md with emojis:


πŸš€ ShortifyGo

ShortifyGo is a URL shortening service built with Go and Docker. It uses Redis for data storage and provides an API to shorten and retrieve URLs.

πŸ“š Table of Contents

πŸ› οΈ Installation

To get started with ShortifyGo, you'll need to have Docker and Docker Compose installed on your machine.

  1. Clone the repository:

    git clone https://github.com/billybillysss/shortifygo.git
    cd shortifygo
  2. Build and start the services:

    docker-compose up --build

πŸš€ Usage

Once the services are up and running, you can access the API at http://localhost:7001.

βœ‚οΈ Shorten a URL

To shorten a URL, send a POST request to /api/v1 with the URL in the request body.

Example:

curl -X POST -d '{"url":"https://www.example.com"}' http://localhost:7001/api/v1

πŸ” Retrieve a URL

To retrieve the original URL, send a GET request to /{shortId}.

Example:

curl http://localhost:7001/retrieve/abc123

πŸ“‚ Project Structure

SHORTIFYGO/
β”œβ”€β”€ .data/
β”œβ”€β”€ api/
β”‚   β”œβ”€β”€ database/
β”‚   β”‚   └── redis.go
β”‚   β”œβ”€β”€ handlers/
β”‚   β”‚   β”œβ”€β”€ retriever.go
β”‚   β”‚   └── shortener.go
β”‚   β”œβ”€β”€ utils/
β”‚   β”œβ”€β”€ .env
β”‚   β”œβ”€β”€ Dockerfile
β”‚   β”œβ”€β”€ go.mod
β”‚   β”œβ”€β”€ go.sum
β”‚   └── main.go
β”œβ”€β”€ db/
β”‚   └── Dockerfile
└── docker-compose.yml

πŸ“„ Description of Files

  • .data/ - Directory for Redis data storage.
  • .env - Environment variables file.
  • api/ - Contains the source code for the API.
    • database/redis.go - Redis client and database operations.
    • handlers/retriever.go - Handler for retrieving URLs.
    • handlers/shortener.go - Handler for shortening URLs.
    • utils/ - Utility functions (if any).
    • .env - Environment variables for the API.
    • Dockerfile - Dockerfile for building the API service.
    • go.mod - Go module file.
    • go.sum - Go dependencies.
    • main.go - Entry point of the API service.
  • db/ - Contains the Dockerfile for the Redis service.
  • docker-compose.yml - Docker Compose file to run the services.

πŸ“‘ Endpoints

POST /api/v1

  • Description: Shortens a given URL.
  • Request Body: JSON containing the URL to be shortened and an optional short code.
    {
      "URL": "https://www.example.com",
      "Short": ""
    }
  • Response Body: JSON containing the status, original URL, short code, remaining requests, and limit reset time.
    {
      "Status": "success",
      "URL": "https://www.example.com",
      "Short": "http://{Domain}/{ShortId}",
      "RemainRequest": 5,
      "LimitRestTime": "2024-05-23T00:00:00Z"
    }

GET /{shortId}

  • Description: Retrieves the original URL for a given shortened code.
  • Path Parameters: shortId - The code representing the shortened URL.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published