Socket
Book a DemoInstallSign in
Socket

github.com/CyrilBaah/URL-Shortener-API

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/CyrilBaah/URL-Shortener-API

v0.0.0-20250830212413-163e2f2e64b8
Source
Go
Version published
Created
Source

URL Shortener API

A simple URL shortener API built with Golang, Gorilla Mux, and Docker. This API allows users to shorten long URLs and redirect using generated short codes.

Features

  • Shorten long URLs
  • Redirect using short URLs
  • In-memory storage for simplicity

Installation & Running

1. Clone the Repository

git clone https://github.com/CyrilBaah/URL-Shortener-API.git
cd URL-Shortener-API

2. Install Dependencies

go mod tidy

3. Run the Server

go run main.go

The server will start on http://localhost:8080.

API Endpoints

Shorten a URL

Endpoint: POST /shorten

Request:

curl -X POST http://localhost:8080/shorten -H "Content-Type: application/json" -d '{"url": "https://example.com"}'

Response:

{
  "short_url": "Pwl3OV"
}

Redirect to Original URL

Endpoint: GET /{short_code}

Example:

curl -L http://localhost:8080/Pwl3OV

Redirects to https://example.com.

Running with Docker

1. Build the Docker Image

docker build -t url-shortener-api .

2. Run the Container

docker run -p 8080:8080 url-shortener-api

curl -v http://localhost:8080/metrics

FAQs

Package last updated on 30 Aug 2025

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

About

Packages

Stay in touch

Get open source security insights delivered straight into your inbox.

  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc

U.S. Patent No. 12,346,443 & 12,314,394. Other pending.