Skip to content

cchhaarroonn/LilShorty

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 

Repository files navigation

LilShorty

A simple URL shortener built with Go and MongoDB.

Requirements

  • Go (v1.16 or higher)
  • MongoDB

Installation

  1. Clone the repository:
git clone https://github.com/cchhaarroonn/LilShorty.git
  1. Change to the project directory:
cd LilShorty
  1. Initialize project and get dependencies:
go mod init <charon/lilshorty>
go get github.com/gin-gonic/gin
go get go.mongodb.org/mongo-driver/mongo
  1. Set up MongoDB by creating a database and a collection. Update the MongoDB connection URL in the code:
client, err := mongo.Connect(ctx, options.Client().ApplyURI("mongodb://<username>:<password>@<host>:<port>")) <line 22>

Usage

  1. Run the application:
go run main.go
  1. The server will start running on locahost:42069 by default change it on line 127

Shortening a URL

Send a POST request to /createShort/:url to shorten a URL. Replace :url with the actual URL you want to shorten.

POST /createShort/http://example.com
{
  "status": "URL shortened, key is: <generated-key>"
}

Redirecting to the Original URL

GET /short/<generated-key>
{
  "status": "<original-url>"
}

Contributing

Contributions are welcome! If you find any issues or want to add new features, please open an issue or submit a pull request.

Note

As always there is a note lmao ... I might make website for this like basic html, css, js but it really depends if I want to burn my brain at some point until then just enjoy using this simple thingy it is not much but is quite good

About

Simple REST API for shortening your urls

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages