Skip to content

High-Performance Shortlink ( Short URL ) app creator in Golang. For privacy reasons, you may prefer to host your own short URL app and this is the one to use.

License

Notifications You must be signed in to change notification settings

go-awesome/shortlink

Repository files navigation

About The Project

Shortlink App in Golang

  • Multiple Node based Architecture to create and scale at ease
  • Highly performant key-value storage system
  • Centralized Storage option when multiple node created - requires tweaking.
  • API auth system not built. Left for using it for your own use case like JWT or paseto. Self Implement.

Please see the architecture file in the repository on option you can use the app. For some minor tweaking may be required.

Built With

List of Library and Framework used in building the app:

Getting Started

Just download and run go run main.go and you are ready to go. To deploy to server, prefer DigitalOcean

Steps

Common Steps to Launch:

go mod tidy
go mod vendor
go run main.go OR go build -ldflags "-s -w" main.go && ./main

Must Changeable Variables in constant.go:

Production      = 2 // Please set to 1 if in production.
Domain          = "https://lin.ks/"
CookieName      = "lin.ks"
NodeID          = "N1|" // Increase per node by value as "N2|", "N3|"... for multiple node
DBFolder        = "/home/ubuntu/go/src/shortlink/db/"
AddFromToken    = 3 // firt N character to get from token and use it in ShortID
ShortIDToken    = 7 // Further added from 1st N char of AddFromToken+NodeID: total=12
APITokenLength  = 32
Click here to see Rest API Example:
  1. Short URL redirector: /:short_code_here
  2. API Routes:
  • /api/create [Post]
Takes `{"url": "https://github.com"}` with `Authorization: Bearer {token}` from Header
  • /api/update [Post]
Takes `{"old": "https://github.com", "new": "https://bitbucket.com", "short": "shortcode"}` with `Authorization: Bearer {token}` from Header
  • /api/delete [Post]
Takes `{ "long": "https://bitbucket.com", "short": "shortcode"}` with `Authorization: Bearer {token}` from Header
  • /api/fetch [GET]
 Takes `Authorization: Bearer {token}` from Header
  • /api/fetch/:short_code_here [GET]
 {short_code_here} in the URL and Takes `Authorization: Bearer {token}` from Header

Note: Remember to implement Auth system of your own and Replace APITokenLength check with your own function.

Please see the rest.http file to understand the request type in live details.

Feature request?

Share your feature request via issue tracker.

Feel like helping out:

  • Via Code Contribution (if any / new feature)
  • BTC: 1Hp24RtL3o86boapSAD3DtyqF5jdq1rfpM
  • Star the repository and watch out for new updates and features.

Do not Forget [ Shortlink App Plan ]

Following Use cases:

  • Self-Hosted URL tracking.
  • Your URL tracking insights is in-house and not hosted or shared with third party.

License

Distributed under the Apache License 2.0. See LICENSE for more information.

About

High-Performance Shortlink ( Short URL ) app creator in Golang. For privacy reasons, you may prefer to host your own short URL app and this is the one to use.

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages