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
orpaseto
. Self Implement.
Please see the architecture
file in the repository on option you can use the app. For some minor tweaking may be required.
List of Library and Framework used in building the app:
Just download and run go run main.go
and you are ready to go.
Common Steps to Launch:
go mod tidy
go mod vendor
go run main.go OR go build -ldflags "-s -w" main.go && ./main
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
- Short URL redirector:
/:short_code_here
- 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.
Share your feature request via issue
tracker.
- Via Code Contribution (if any / new feature)
- BTC:
1Hp24RtL3o86boapSAD3DtyqF5jdq1rfpM
- Star the repository and watch out for new updates and features.
- Checkout the Shortlink App plan PDF file for more understanding about the Repo:
Distributed under the Apache License 2.0. See LICENSE
for more information.