Skip to content

Vladimir-Dimitrov-Ngu/shortUrl

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

6 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

ShortUrl

URL Shortener is a server application that transforms long web links into shorter, more manageable ones.

Description

URL Shortener allows users to create short URLs for long web links. This can be useful for shortening lengthy links in messages, text messages, or on social media, making them more convenient to share.

Installation

  1. Clone the repository:
git clone https://github.com/your_username/url-shortener.git
  1. Navigate to the project directory:
cd url-shortener
  1. Build the Go application:
go build .
  1. Run the application
go run main.go

Usage

Creating a Short Link

Send a POST request to /api/urls with a JSON body containing the long URL:

POST /api/urls HTTP/1.1
Content-Type: application/json

{
    "url": "https://example.com/very-long-url-that-we-want-to-shorten"
}

Or

curl -XPOST http:https://Localhost:8080/api/urls -d '{"url": "https://example.com/very-long-url-that-we-want-to-shorten"}'

Receive a response with the short URL:

{
    "key": "0ve6V"
}

Redirecting with Short Link

Open a browser and enter the URL in the format http:https://your-server/{key}, where {key} is the key obtained after creating the short link. For example:

http:https://your-server/0ve6V

API

POST /api/urls

Creates a short link.

Request Body Parameters

Parameter Type Description
Url String The long URL to be shortened.

GET /{key}

Redirects to the long URL associated with the short key.

Path Parameters

Parameter Type Description
key String The short key created when URL is added.

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published