Giovanni Rezcjikov d386eda958
Some checks failed
continuous-integration/drone/push Build encountered an error
.drone.yml and docker-compose.yml fix
2026-02-21 16:25:41 +03:00
2026-02-06 21:08:15 +03:00
2026-02-06 21:08:15 +03:00
2026-02-21 15:50:51 +03:00
2026-02-06 21:08:15 +03:00
2026-02-21 15:50:51 +03:00
2026-02-21 15:50:51 +03:00
2026-02-06 21:13:38 +03:00

Link Shortener

A simple and fast URL shortener service built with Go and Redis.

Features

  • Shorten long URLs into compact short links
  • Redirect short links to original URLs
  • 30-day expiration for stored links

Getting Started

Prerequisites

  • Docker and Docker Compose

Installation & Running

  1. Clone the repository:
git clone https://github.com/dusiburg/link-shortener
cd link-shortener
  1. Start the application with docker compose:
docker compose up

The service will be available at http://localhost:8080

API Endpoints

Request:

GET /l/{original-url}

Example:

curl "http://localhost:8080/l/https://example.com/very/long/url"

Response:

{
  "status": "success",
  "short_link": "http://localhost:8080/r/abc123xyz",
  "original_link": "https://example.com/very/long/url",
  "expires_in": "30d"
}

Request:

GET /r/{short-id}

Example:

curl "http://localhost:8080/r/abc123xyz"

This will redirect to the original URL.

Health Check

Request:

GET /ping

Response:

{
  "status": "success"
}

Configuration

Environment variables can be set via .env file or docker compose:

  • SERVER_HOST - Server host (default: localhost)
  • SERVER_PORT - Server port (default: 8080)
  • REDIS_URL - Redis connection URL (required)

Project Structure

.
├── cmd/
│   └── main.go              # Application entry point
├── internal/
│   ├── config/              # Configuration management
│   ├── db/                  # Database connections
│   ├── handlers/            # HTTP request handlers
│   ├── http/                # HTTP server setup
│   ├── repositories/        # Data access layer
│   └── services/            # Business logic
├── docker-compose.yml       # Docker Compose configuration
├── Dockerfile               # Multi-stage Docker build
└── README                   # This file

Development

To build locally without Docker:

go build -o bin/application ./cmd
./bin/application

Make sure Redis is running before starting the application.

Description
No description provided
Readme 77 KiB
Languages
Go 100%