url-shortener

command module
v0.0.0-...-6457f5f Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 19, 2024 License: MIT Imports: 4 Imported by: 0

README

url-shortener

A simple demo written in Golang to shorten URL and redirect

.
├── go.mod
├── go.sum
├── handler
│   └── handlers.go
├── main.go
├── shortener
│   ├── shorturl_generator.go
│   └── shorturl_generator_test.go
└── store
    ├── store_service.go
    └── store_service_test.go

background

These small utilities services are quite helpful in reducing noise when sharing links. You can input a very long URL address and it can output a much shorter version of it much easier to share around.

setup envs

  • go 1.17
  • redis 3.2

how it works

  • storage layer
  • short link generator
    • using SHA256 to hash the initial inputs
    • using BASE58 binary to text encoding
  • forwarding
    • get the creation request body, parse it and extract the initial long url and userId
    • generate our shortened hash using shortener.GenerateShortLink()
    • store the mapping of output hash/shortUrl with the initial long url using store.SaveUrlMapping()

reference

Let's build a URL shortener in Go - EDDY WANNY M

Documentation

The Go Gopher

There is no documentation for this package.

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL