Skip to content

harshitrajsinha/go-url-shortener

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

21 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

GShortify

⭐ Introduction

GShortify, a URL Shortener application built to demonstrate intermediate CRUD operations that can be performed using Golang. It involves the creation and consumption of APIs, allowing to shorten and manage URLs efficiently, while showcasing key concepts such as data handling, routing, and database interaction.

GShortify

🔨 Tech Stack

  • HTML/CSS/Javascript (Frontend)
  • Go (Backend)
  • Supabase (Database)

📜 Features

👉 API Creation: using gorilla/mux package to serve different endpoints for URL shortener

👉 API consumption: by the UI application to shorten a long URL

🔧 API Endpoints

Method Endpoint Description
GET /api/v1/routes/redirect/:shortid Redirect to original URL
GET /api/v1/routes/urls List all URLs and corresponding shorten id
POST /api/v1/routes/shorten Create shorten id and shorten URL
PUT /api/v1/routes/update/:shortid Update original URL
DELETE /api/v1/routes/update/:shortid Update original URL and corresponding shorten id
List original URL and corresponding shortID

GET /api/v1/urls

Request

  • Client's IP Address

Response

{
  "code": 200,
  "message": "Data found",
  "data": [
    {
      "tw9apb98": "https://google.com"
    },
    {
      "ngMI98wQ": "https://yahoo.com"
    },
    {
      "O8dYvXGH": "https://netflix.com"
    },
    {
      "d9jYcHDU": "https://zee5.com"
    }
  ]
}
Shorten long URL

POST /api/v1/shorten

Request

{
  "url": "https://linkedin.com"
}

Response

{
  "code": 201,
  "message": "Shorten url generated successfully",
  "data": {
    "shortened-url": [
      {
        "localhost:8080/z5VAZ6bN"
      }
    ]
  }
}
Update original URL

PUT /api/v1/update/:shortid

Request

{
  "url": "https://google.co.in"
}

Response

{
  "code": 200,
  "message": "Data updated successfully",
  "data": [
    {
    "previous-url": "https://google.com",
    "original-url": "https://google.co.in",
    "short-id": "tw9apb98"
    }
  ]
}
Delete original URL and corresponding shortID

DELETE /api/v1/delete/:shortid

Response

204 No Content

About

A URL Shortener application built using golang to shorten and manage URLs efficiently and stored via supabase

Topics

Resources

Stars

Watchers

Forks

Releases

No releases published

Contributors